Sha256: 20fc0fd6dc55c1e7e9ada2e827eb2d9b81f700a150bfc9fc04e3d519ce823614

Contents?: true

Size: 1.24 KB

Versions: 39

Compression:

Stored size: 1.24 KB

Contents

require 'em_test_helper'

class TestConnectionCount < Test::Unit::TestCase
  def test_idle_connection_count
    EM.run {
      $count = EM.connection_count
      EM.stop_event_loop
    }

    assert_equal(0, $count)
  end

  module Client
    def connection_completed
      $client_conns += 1
      EM.stop if $client_conns == 3
    end
  end

  def test_with_some_connections
    EM.run {
      $client_conns = 0
      $initial_conns = EM.connection_count
      EM.start_server("127.0.0.1", 9999)
      $server_conns = EM.connection_count
      3.times { EM.connect("127.0.0.1", 9999, Client) }
    }

    assert_equal(0, $initial_conns)
    assert_equal(1, $server_conns)
    assert_equal(4, $client_conns + $server_conns)
  end

  module DoubleCloseClient
    def unbind
      close_connection
      $num_close_scheduled_1 = EM.num_close_scheduled
      EM.next_tick do
        $num_close_scheduled_2 = EM.num_close_scheduled
        EM.stop
      end
    end
  end

  def test_num_close_scheduled
    omit_if(jruby?)
    EM.run {
      assert_equal(0, EM.num_close_scheduled)
      EM.connect("127.0.0.1", 9999, DoubleCloseClient) # nothing listening on 9999
    }
    assert_equal(1, $num_close_scheduled_1)
    assert_equal(0, $num_close_scheduled_2)
  end
end

Version data entries

39 entries across 38 versions & 4 rubygems

Version Path
sensu-em-2.7.0-java tests/test_connection_count.rb
arcabouco-0.2.13 vendor/bundle/gems/eventmachine-1.2.1/tests/test_connection_count.rb
arcabouco-0.2.13 vendor/bundle/gems/eventmachine-1.2.0.1/tests/test_connection_count.rb
eventmachine-1.2.1-java tests/test_connection_count.rb
eventmachine-1.2.1-x64-mingw32 tests/test_connection_count.rb
eventmachine-1.2.1-x86-mingw32 tests/test_connection_count.rb
eventmachine-1.2.1 tests/test_connection_count.rb
ish_lib_manager-0.0.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/eventmachine-1.2.0.1/tests/test_connection_count.rb
sensu-em-2.6.0-java tests/test_connection_count.rb
eventmachine-1.2.0.1-java tests/test_connection_count.rb
eventmachine-1.2.0.1-x86-mingw32 tests/test_connection_count.rb
eventmachine-1.2.0.1-x64-mingw32 tests/test_connection_count.rb
eventmachine-1.2.0.1 tests/test_connection_count.rb
eventmachine-1.2.0 tests/test_connection_count.rb
eventmachine-1.2.0-x86-mingw32 tests/test_connection_count.rb
eventmachine-1.2.0-x64-mingw32 tests/test_connection_count.rb
eventmachine-1.2.0.dev.2 tests/test_connection_count.rb
eventmachine-1.2.0.dev.2-x86-mingw32 tests/test_connection_count.rb
eventmachine-1.2.0.dev.2-x64-mingw32 tests/test_connection_count.rb
eventmachine-1.0.9.1 tests/test_connection_count.rb