eventmachine 1.0.9.1-java → 1.2.0.1-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +26 -0
  3. data/README.md +2 -2
  4. data/ext/cmain.cpp +77 -5
  5. data/ext/ed.cpp +112 -42
  6. data/ext/ed.h +27 -13
  7. data/ext/em.cpp +105 -163
  8. data/ext/em.h +10 -7
  9. data/ext/eventmachine.h +13 -1
  10. data/ext/extconf.rb +23 -14
  11. data/ext/fastfilereader/extconf.rb +1 -2
  12. data/ext/fastfilereader/rubymain.cpp +6 -6
  13. data/ext/project.h +9 -4
  14. data/ext/rubymain.cpp +155 -36
  15. data/ext/ssl.cpp +157 -13
  16. data/ext/ssl.h +7 -2
  17. data/lib/em/channel.rb +5 -0
  18. data/lib/em/completion.rb +2 -2
  19. data/lib/em/connection.rb +61 -3
  20. data/lib/em/iterator.rb +26 -5
  21. data/lib/em/pool.rb +1 -1
  22. data/lib/em/protocols/line_and_text.rb +1 -1
  23. data/lib/em/pure_ruby.rb +6 -1
  24. data/lib/em/queue.rb +16 -7
  25. data/lib/em/resolver.rb +46 -23
  26. data/lib/em/threaded_resource.rb +2 -2
  27. data/lib/em/version.rb +1 -1
  28. data/lib/eventmachine.rb +59 -42
  29. data/lib/rubyeventmachine.jar +0 -0
  30. data/rakelib/package.rake +23 -1
  31. data/tests/dhparam.pem +13 -0
  32. data/tests/em_test_helper.rb +79 -0
  33. data/tests/test_basic.rb +17 -26
  34. data/tests/test_channel.rb +14 -1
  35. data/tests/test_connection_write.rb +2 -2
  36. data/tests/test_defer.rb +17 -0
  37. data/tests/test_epoll.rb +1 -1
  38. data/tests/test_fork.rb +75 -0
  39. data/tests/test_ipv4.rb +125 -0
  40. data/tests/test_ipv6.rb +131 -0
  41. data/tests/test_iterator.rb +18 -0
  42. data/tests/test_many_fds.rb +1 -1
  43. data/tests/test_queue.rb +14 -0
  44. data/tests/test_resolver.rb +23 -0
  45. data/tests/test_set_sock_opt.rb +2 -0
  46. data/tests/test_ssl_dhparam.rb +83 -0
  47. data/tests/test_ssl_ecdh_curve.rb +79 -0
  48. data/tests/test_ssl_extensions.rb +49 -0
  49. data/tests/test_ssl_methods.rb +19 -0
  50. data/tests/test_ssl_protocols.rb +246 -0
  51. data/tests/test_ssl_verify.rb +44 -0
  52. data/tests/test_system.rb +4 -0
  53. data/tests/test_unbind_reason.rb +5 -1
  54. metadata +101 -20
  55. data/.gitignore +0 -21
  56. data/.travis.yml +0 -22
  57. data/.yardopts +0 -7
  58. data/Gemfile +0 -2
  59. data/Rakefile +0 -20
  60. data/eventmachine.gemspec +0 -38
  61. data/rakelib/cpp.rake_example +0 -77
@@ -21,6 +21,22 @@ class TestIterator < Test::Unit::TestCase
21
21
  assert_equal(list.to_a.sort, items.values.flatten.sort)
22
22
  end
23
23
 
24
+ def test_default_concurrency_with_a_proc
25
+ items = {}
26
+ list = (1..10).to_a
27
+ original_list = list.dup
28
+ EM.run {
29
+ EM::Iterator.new(proc{list.pop || EM::Iterator::Stop}).each( proc {|num,iter|
30
+ time = get_time
31
+ items[time] ||= []
32
+ items[time] << num
33
+ EM::Timer.new(1) {iter.next}
34
+ }, proc {EM.stop})
35
+ }
36
+ assert_equal(10, items.keys.size)
37
+ assert_equal(original_list.to_a.sort, items.values.flatten.sort)
38
+ end
39
+
24
40
  def test_concurrency_bigger_than_list_size
25
41
  items = {}
26
42
  list = [1,2,3]
@@ -72,6 +88,8 @@ class TestIterator < Test::Unit::TestCase
72
88
  end
73
89
 
74
90
  def test_inject
91
+ omit_if(windows?)
92
+
75
93
  list = %w[ pwd uptime uname date ]
76
94
  EM.run {
77
95
  EM::Iterator.new(list, 2).inject({}, proc{ |hash,cmd,iter|
@@ -9,7 +9,7 @@ class TestManyFDs < Test::Unit::TestCase
9
9
  def test_connection_class_cache
10
10
  mod = Module.new
11
11
  a = nil
12
- Process.setrlimit(Process::RLIMIT_NOFILE,4096);
12
+ Process.setrlimit(Process::RLIMIT_NOFILE, 4096) rescue nil
13
13
  EM.run {
14
14
  EM.start_server '127.0.0.1', @port, mod
15
15
  1100.times do
data/tests/test_queue.rb CHANGED
@@ -47,4 +47,18 @@ class TestEMQueue < Test::Unit::TestCase
47
47
  EM.run { EM.next_tick { EM.stop } }
48
48
  assert_equal many, q.num_waiting
49
49
  end
50
+
51
+ def test_big_queue
52
+ EM.run do
53
+ q = EM::Queue.new
54
+ 2000.times do |i|
55
+ q.push(*0..1000)
56
+ q.pop { |v| assert_equal v, i % 1001 }
57
+ end
58
+ q.pop do
59
+ assert_equal 1_999_999, q.size
60
+ EM.stop
61
+ end
62
+ end
63
+ end
50
64
  end
@@ -1,7 +1,24 @@
1
1
  require 'em_test_helper'
2
2
 
3
3
  class TestResolver < Test::Unit::TestCase
4
+ def test_nameserver
5
+ assert_kind_of(String, EM::DNS::Resolver.nameserver)
6
+ end
7
+
8
+ def test_nameservers
9
+ assert_kind_of(Array, EM::DNS::Resolver.nameservers)
10
+ end
11
+
12
+ def test_hosts
13
+ assert_kind_of(Hash, EM::DNS::Resolver.hosts)
14
+
15
+ # Make sure that blank or comment lines are skipped
16
+ refute(EM::DNS::Resolver.hosts.include? nil)
17
+ end
18
+
4
19
  def test_a
20
+ pend('FIXME: this test is broken on Windows') if windows?
21
+
5
22
  EM.run {
6
23
  d = EM::DNS::Resolver.resolve "google.com"
7
24
  d.errback { assert false }
@@ -29,6 +46,8 @@ class TestResolver < Test::Unit::TestCase
29
46
  end
30
47
 
31
48
  def test_a_pair
49
+ pend('FIXME: this test is broken on Windows') if windows?
50
+
32
51
  EM.run {
33
52
  d = EM::DNS::Resolver.resolve "yahoo.com"
34
53
  d.errback { |err| assert false, "failed to resolve yahoo.com: #{err}" }
@@ -41,6 +60,8 @@ class TestResolver < Test::Unit::TestCase
41
60
  end
42
61
 
43
62
  def test_localhost
63
+ pend('FIXME: this test is broken on Windows') if windows?
64
+
44
65
  EM.run {
45
66
  d = EM::DNS::Resolver.resolve "localhost"
46
67
  d.errback { assert false }
@@ -54,6 +75,8 @@ class TestResolver < Test::Unit::TestCase
54
75
  end
55
76
 
56
77
  def test_timer_cleanup
78
+ pend('FIXME: this test is broken on Windows') if windows?
79
+
57
80
  EM.run {
58
81
  d = EM::DNS::Resolver.resolve "google.com"
59
82
  d.errback { |err| assert false, "failed to resolve google.com: #{err}" }
@@ -15,6 +15,8 @@ class TestSetSockOpt < Test::Unit::TestCase
15
15
  #-------------------------------------
16
16
 
17
17
  def test_set_sock_opt
18
+ omit_if(windows?)
19
+
18
20
  test = self
19
21
  EM.run do
20
22
  EM.connect 'google.com', 80, Module.new {
@@ -0,0 +1,83 @@
1
+ require 'em_test_helper'
2
+
3
+ class TestSslDhParam < Test::Unit::TestCase
4
+ def setup
5
+ $dir = File.dirname(File.expand_path(__FILE__)) + '/'
6
+ $dhparam_file = File.join($dir, 'dhparam.pem')
7
+ end
8
+
9
+ module Client
10
+ def connection_completed
11
+ start_tls
12
+ end
13
+
14
+ def ssl_handshake_completed
15
+ $client_handshake_completed = true
16
+ $client_cipher_name = get_cipher_name
17
+ close_connection
18
+ end
19
+
20
+ def unbind
21
+ EM.stop_event_loop
22
+ end
23
+ end
24
+
25
+ module Server
26
+ def post_init
27
+ start_tls(:dhparam => $dhparam_file, :cipher_list => "DHE,EDH")
28
+ end
29
+
30
+ def ssl_handshake_completed
31
+ $server_handshake_completed = true
32
+ $server_cipher_name = get_cipher_name
33
+ end
34
+ end
35
+
36
+ module NoDhServer
37
+ def post_init
38
+ start_tls(:cipher_list => "DHE,EDH")
39
+ end
40
+
41
+ def ssl_handshake_completed
42
+ $server_handshake_completed = true
43
+ $server_cipher_name = get_cipher_name
44
+ end
45
+ end
46
+
47
+ def test_no_dhparam
48
+ omit_unless(EM.ssl?)
49
+ omit_if(rbx?)
50
+
51
+ $client_handshake_completed, $server_handshake_completed = false, false
52
+ $server_cipher_name, $client_cipher_name = nil, nil
53
+
54
+ EM.run {
55
+ EM.start_server("127.0.0.1", 16784, NoDhServer)
56
+ EM.connect("127.0.0.1", 16784, Client)
57
+ }
58
+
59
+ assert(!$client_handshake_completed)
60
+ assert(!$server_handshake_completed)
61
+ end
62
+
63
+ def test_dhparam
64
+ omit_unless(EM.ssl?)
65
+ omit_if(rbx?)
66
+
67
+ $client_handshake_completed, $server_handshake_completed = false, false
68
+ $server_cipher_name, $client_cipher_name = nil, nil
69
+
70
+ EM.run {
71
+ EM.start_server("127.0.0.1", 16784, Server)
72
+ EM.connect("127.0.0.1", 16784, Client)
73
+ }
74
+
75
+ assert($client_handshake_completed)
76
+ assert($server_handshake_completed)
77
+
78
+ assert($client_cipher_name.length > 0)
79
+ assert_equal($client_cipher_name, $server_cipher_name)
80
+
81
+ assert_match(/^(DHE|EDH)/, $client_cipher_name)
82
+ end
83
+ end
@@ -0,0 +1,79 @@
1
+ require 'em_test_helper'
2
+
3
+ class TestSslEcdhCurve < Test::Unit::TestCase
4
+ module Client
5
+ def connection_completed
6
+ start_tls
7
+ end
8
+
9
+ def ssl_handshake_completed
10
+ $client_handshake_completed = true
11
+ $client_cipher_name = get_cipher_name
12
+ close_connection
13
+ end
14
+
15
+ def unbind
16
+ EM.stop_event_loop
17
+ end
18
+ end
19
+
20
+ module Server
21
+ def post_init
22
+ start_tls(:ecdh_curve => "prime256v1", :cipher_list => "ECDH")
23
+ end
24
+
25
+ def ssl_handshake_completed
26
+ $server_handshake_completed = true
27
+ $server_cipher_name = get_cipher_name
28
+ end
29
+ end
30
+
31
+ module NoCurveServer
32
+ def post_init
33
+ start_tls(:cipher_list => "ECDH")
34
+ end
35
+
36
+ def ssl_handshake_completed
37
+ $server_handshake_completed = true
38
+ $server_cipher_name = get_cipher_name
39
+ end
40
+ end
41
+
42
+ def test_no_ecdh_curve
43
+ omit_unless(EM.ssl?)
44
+ omit_if(rbx?)
45
+
46
+ $client_handshake_completed, $server_handshake_completed = false, false
47
+
48
+ EM.run {
49
+ EM.start_server("127.0.0.1", 16784, NoCurveServer)
50
+ EM.connect("127.0.0.1", 16784, Client)
51
+ }
52
+
53
+ assert(!$client_handshake_completed)
54
+ assert(!$server_handshake_completed)
55
+ end
56
+
57
+ def test_ecdh_curve
58
+ omit_unless(EM.ssl?)
59
+ omit_if(rbx?)
60
+
61
+ $client_handshake_completed, $server_handshake_completed = false, false
62
+ $server_cipher_name, $client_cipher_name = nil, nil
63
+
64
+ EM.run {
65
+ EM.start_server("127.0.0.1", 16784, Server)
66
+ EM.connect("127.0.0.1", 16784, Client)
67
+ }
68
+
69
+ assert($client_handshake_completed)
70
+ assert($server_handshake_completed)
71
+
72
+ assert($client_cipher_name.length > 0)
73
+ assert_equal($client_cipher_name, $server_cipher_name)
74
+
75
+ assert_match(/^(AECDH|ECDHE)/, $client_cipher_name)
76
+ end
77
+
78
+
79
+ end
@@ -0,0 +1,49 @@
1
+ require 'em_test_helper'
2
+
3
+ require 'socket'
4
+ require 'openssl'
5
+
6
+ if EM.ssl?
7
+ class TestSslExtensions < Test::Unit::TestCase
8
+
9
+ module Client
10
+ def ssl_handshake_completed
11
+ $client_handshake_completed = true
12
+ close_connection
13
+ end
14
+
15
+ def unbind
16
+ EM.stop_event_loop
17
+ end
18
+
19
+ def connection_completed
20
+ start_tls(:ssl_version => :tlsv1, :sni_hostname => 'example.com')
21
+ end
22
+ end
23
+
24
+ module Server
25
+ def ssl_handshake_completed
26
+ $server_handshake_completed = true
27
+ $server_sni_hostname = get_sni_hostname
28
+ end
29
+
30
+ def post_init
31
+ start_tls(:ssl_version => :TLSv1)
32
+ end
33
+ end
34
+
35
+ def test_tlsext_sni_hostname
36
+ $server_handshake_completed = false
37
+
38
+ EM.run do
39
+ EM.start_server("127.0.0.1", 16784, Server)
40
+ EM.connect("127.0.0.1", 16784, Client)
41
+ end
42
+
43
+ assert($server_handshake_completed)
44
+ assert_equal('example.com', $server_sni_hostname)
45
+ end
46
+ end
47
+ else
48
+ warn "EM built without SSL support, skipping tests in #{__FILE__}"
49
+ end
@@ -10,6 +10,9 @@ class TestSSLMethods < Test::Unit::TestCase
10
10
  def ssl_handshake_completed
11
11
  $server_called_back = true
12
12
  $server_cert_value = get_peer_cert
13
+ $server_cipher_bits = get_cipher_bits
14
+ $server_cipher_name = get_cipher_name
15
+ $server_cipher_protocol = get_cipher_protocol
13
16
  end
14
17
  end
15
18
 
@@ -21,6 +24,9 @@ class TestSSLMethods < Test::Unit::TestCase
21
24
  def ssl_handshake_completed
22
25
  $client_called_back = true
23
26
  $client_cert_value = get_peer_cert
27
+ $client_cipher_bits = get_cipher_bits
28
+ $client_cipher_name = get_cipher_name
29
+ $client_cipher_protocol = get_cipher_protocol
24
30
  EM.stop_event_loop
25
31
  end
26
32
  end
@@ -30,6 +36,9 @@ class TestSSLMethods < Test::Unit::TestCase
30
36
  omit_if(rbx?)
31
37
  $server_called_back, $client_called_back = false, false
32
38
  $server_cert_value, $client_cert_value = nil, nil
39
+ $server_cipher_bits, $client_cipher_bits = nil, nil
40
+ $server_cipher_name, $client_cipher_name = nil, nil
41
+ $server_cipher_protocol, $client_cipher_protocol = nil, nil
33
42
 
34
43
  EM.run {
35
44
  EM.start_server("127.0.0.1", 9999, ServerHandler)
@@ -41,6 +50,16 @@ class TestSSLMethods < Test::Unit::TestCase
41
50
 
42
51
  assert($server_cert_value.is_a?(NilClass))
43
52
  assert($client_cert_value.is_a?(String))
53
+
54
+ assert($client_cipher_bits > 0)
55
+ assert_equal($client_cipher_bits, $server_cipher_bits)
56
+
57
+ assert($client_cipher_name.length > 0)
58
+ assert_match(/AES/, $client_cipher_name)
59
+ assert_equal($client_cipher_name, $server_cipher_name)
60
+
61
+ assert_match(/TLS/, $client_cipher_protocol)
62
+ assert_equal($client_cipher_protocol, $server_cipher_protocol)
44
63
  end
45
64
 
46
65
  end
@@ -0,0 +1,246 @@
1
+ require 'em_test_helper'
2
+
3
+ require 'socket'
4
+ require 'openssl'
5
+
6
+ if EM.ssl?
7
+ class TestSslProtocols < Test::Unit::TestCase
8
+
9
+ module Client
10
+ def ssl_handshake_completed
11
+ $client_handshake_completed = true
12
+ close_connection
13
+ end
14
+
15
+ def unbind
16
+ EM.stop_event_loop
17
+ end
18
+ end
19
+
20
+ module Server
21
+ def ssl_handshake_completed
22
+ $server_handshake_completed = true
23
+ end
24
+ end
25
+
26
+ module ClientAny
27
+ include Client
28
+ def connection_completed
29
+ start_tls(:ssl_version => %w(sslv2 sslv3 tlsv1 tlsv1_1 tlsv1_2))
30
+ end
31
+ end
32
+
33
+ module ClientDefault
34
+ include Client
35
+ def connection_completed
36
+ start_tls
37
+ end
38
+ end
39
+
40
+ module ClientSSLv3
41
+ include Client
42
+ def connection_completed
43
+ start_tls(:ssl_version => %w(SSLv3))
44
+ end
45
+ end
46
+
47
+ module ServerSSLv3
48
+ include Server
49
+ def post_init
50
+ start_tls(:ssl_version => %w(SSLv3))
51
+ end
52
+ end
53
+
54
+ module ServerTLSv1CaseInsensitive
55
+ include Server
56
+ def post_init
57
+ start_tls(:ssl_version => %w(tlsv1))
58
+ end
59
+ end
60
+
61
+ module ServerAny
62
+ include Server
63
+ def post_init
64
+ start_tls(:ssl_version => %w(sslv2 sslv3 tlsv1 tlsv1_1 tlsv1_2))
65
+ end
66
+ end
67
+
68
+ module ServerDefault
69
+ include Server
70
+ def post_init
71
+ start_tls
72
+ end
73
+ end
74
+
75
+ module InvalidProtocol
76
+ include Client
77
+ def post_init
78
+ start_tls(:ssl_version => %w(tlsv1 badinput))
79
+ end
80
+ end
81
+
82
+ def test_invalid_ssl_version
83
+ assert_raises(RuntimeError, "Unrecognized SSL/TLS Version: badinput") do
84
+ EM.run do
85
+ EM.start_server("127.0.0.1", 16784, InvalidProtocol)
86
+ EM.connect("127.0.0.1", 16784, InvalidProtocol)
87
+ end
88
+ end
89
+ end
90
+
91
+ def test_any_to_v3
92
+ $client_handshake_completed, $server_handshake_completed = false, false
93
+ EM.run do
94
+ EM.start_server("127.0.0.1", 16784, ServerSSLv3)
95
+ EM.connect("127.0.0.1", 16784, ClientAny)
96
+ end
97
+
98
+ assert($client_handshake_completed)
99
+ assert($server_handshake_completed)
100
+ end
101
+
102
+ def test_case_insensitivity
103
+ $client_handshake_completed, $server_handshake_completed = false, false
104
+ EM.run do
105
+ EM.start_server("127.0.0.1", 16784, ServerTLSv1CaseInsensitive)
106
+ EM.connect("127.0.0.1", 16784, ClientAny)
107
+ end
108
+
109
+ assert($client_handshake_completed)
110
+ assert($server_handshake_completed)
111
+ end
112
+
113
+ def test_v3_to_any
114
+ $client_handshake_completed, $server_handshake_completed = false, false
115
+ EM.run do
116
+ EM.start_server("127.0.0.1", 16784, ServerAny)
117
+ EM.connect("127.0.0.1", 16784, ClientSSLv3)
118
+ end
119
+
120
+ assert($client_handshake_completed)
121
+ assert($server_handshake_completed)
122
+ end
123
+
124
+ def test_v3_to_v3
125
+ $client_handshake_completed, $server_handshake_completed = false, false
126
+ EM.run do
127
+ EM.start_server("127.0.0.1", 16784, ServerSSLv3)
128
+ EM.connect("127.0.0.1", 16784, ClientSSLv3)
129
+ end
130
+
131
+ assert($client_handshake_completed)
132
+ assert($server_handshake_completed)
133
+ end
134
+
135
+ def test_any_to_any
136
+ $client_handshake_completed, $server_handshake_completed = false, false
137
+ EM.run do
138
+ EM.start_server("127.0.0.1", 16784, ServerAny)
139
+ EM.connect("127.0.0.1", 16784, ClientAny)
140
+ end
141
+
142
+ assert($client_handshake_completed)
143
+ assert($server_handshake_completed)
144
+ end
145
+
146
+ def test_default_to_default
147
+ $client_handshake_completed, $server_handshake_completed = false, false
148
+ EM.run do
149
+ EM.start_server("127.0.0.1", 16784, ServerDefault)
150
+ EM.connect("127.0.0.1", 16784, ClientDefault)
151
+ end
152
+
153
+ assert($client_handshake_completed)
154
+ assert($server_handshake_completed)
155
+ end
156
+
157
+ module ServerV3StopAfterHandshake
158
+ def post_init
159
+ start_tls(:ssl_version => %w(SSLv3))
160
+ end
161
+
162
+ def ssl_handshake_completed
163
+ $server_handshake_completed = true
164
+ EM.stop_event_loop
165
+ end
166
+ end
167
+
168
+ module ServerTLSv1StopAfterHandshake
169
+ def post_init
170
+ start_tls(:ssl_version => %w(TLSv1))
171
+ end
172
+
173
+ def ssl_handshake_completed
174
+ $server_handshake_completed = true
175
+ EM.stop_event_loop
176
+ end
177
+ end
178
+
179
+ def test_v3_with_external_client
180
+ $server_handshake_completed = false
181
+ EM.run do
182
+ setup_timeout(2)
183
+ EM.start_server("127.0.0.1", 16784, ServerV3StopAfterHandshake)
184
+ EM.defer do
185
+ sock = TCPSocket.new("127.0.0.1", 16784)
186
+ ctx = OpenSSL::SSL::SSLContext.new
187
+ ctx.ssl_version = :SSLv3_client
188
+ ssl = OpenSSL::SSL::SSLSocket.new(sock, ctx)
189
+ ssl.connect
190
+ ssl.close rescue nil
191
+ sock.close rescue nil
192
+ end
193
+ end
194
+
195
+ assert($server_handshake_completed)
196
+ end
197
+
198
+ def test_tlsv1_with_external_client
199
+ $server_handshake_completed = false
200
+ EM.run do
201
+ setup_timeout(2)
202
+ EM.start_server("127.0.0.1", 16784, ServerTLSv1StopAfterHandshake)
203
+ EM.defer do
204
+ sock = TCPSocket.new("127.0.0.1", 16784)
205
+ ctx = OpenSSL::SSL::SSLContext.new
206
+ ctx.ssl_version = :TLSv1_client
207
+ ssl = OpenSSL::SSL::SSLSocket.new(sock, ctx)
208
+ ssl.connect
209
+ ssl.close rescue nil
210
+ sock.close rescue nil
211
+ end
212
+ end
213
+
214
+ assert($server_handshake_completed)
215
+ end
216
+
217
+ def test_tlsv1_required_with_external_client
218
+ $server_handshake_completed = false
219
+
220
+ EM.run do
221
+ n = 0
222
+ EM.add_periodic_timer(0.5) do
223
+ n += 1
224
+ (EM.stop rescue nil) if n == 2
225
+ end
226
+ EM.start_server("127.0.0.1", 16784, ServerTLSv1StopAfterHandshake)
227
+ EM.defer do
228
+ sock = TCPSocket.new("127.0.0.1", 16784)
229
+ ctx = OpenSSL::SSL::SSLContext.new
230
+ ctx.ssl_version = :SSLv3_client
231
+ ssl = OpenSSL::SSL::SSLSocket.new(sock, ctx)
232
+ assert_raise OpenSSL::SSL::SSLError do
233
+ ssl.connect
234
+ end
235
+ ssl.close rescue nil
236
+ sock.close rescue nil
237
+ EM.stop rescue nil
238
+ end
239
+ end
240
+
241
+ assert(!$server_handshake_completed)
242
+ end
243
+ end
244
+ else
245
+ warn "EM built without SSL support, skipping tests in #{__FILE__}"
246
+ end