Class: TestConnectionCount

Inherits:
Test::Unit::TestCase
  • Object
show all
Defined in:
lib/ext/eventmachine-0.12.10/tests/test_connection_count.rb

Defined Under Namespace

Modules: Client

Instance Method Summary collapse

Instance Method Details

#test_idle_connection_countObject



6
7
8
9
10
11
12
13
# File 'lib/ext/eventmachine-0.12.10/tests/test_connection_count.rb', line 6

def test_idle_connection_count
  EM.run {
    $count = EM.connection_count
    EM.stop_event_loop
  }

  assert_equal(0, $count)
end

#test_with_some_connectionsObject



22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/ext/eventmachine-0.12.10/tests/test_connection_count.rb', line 22

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