eventmachine 1.0.0.beta.2-x86-mswin32-60 → 1.0.0.beta.3-x86-mswin32-60
Sign up to get free protection for your applications and to get access to all the features.
- data/.yardopts +3 -0
- data/Gemfile +1 -0
- data/eventmachine.gemspec +1 -3
- data/ext/cmain.cpp +4 -4
- data/ext/ed.cpp +13 -16
- data/ext/ed.h +9 -10
- data/ext/em.cpp +14 -24
- data/ext/eventmachine.h +2 -2
- data/ext/extconf.rb +1 -1
- data/ext/rubymain.cpp +8 -6
- data/lib/em/connection.rb +3 -1
- data/lib/em/pure_ruby.rb +17 -17
- data/lib/em/resolver.rb +186 -0
- data/lib/em/spawnable.rb +3 -7
- data/lib/em/version.rb +1 -1
- data/lib/eventmachine.rb +6 -4
- data/lib/jeventmachine.rb +1 -1
- data/tasks/package.rake +4 -1
- data/tasks/test.rake +1 -0
- data/tests/em_test_helper.rb +55 -0
- data/tests/test_attach.rb +46 -56
- data/tests/test_basic.rb +74 -96
- data/tests/test_channel.rb +2 -4
- data/tests/test_connection_count.rb +1 -3
- data/tests/test_defer.rb +13 -44
- data/tests/test_deferrable.rb +19 -19
- data/tests/test_epoll.rb +25 -55
- data/tests/test_error_handler.rb +10 -7
- data/tests/test_exc.rb +6 -33
- data/tests/test_file_watch.rb +51 -35
- data/tests/test_futures.rb +9 -37
- data/tests/test_get_sock_opt.rb +27 -20
- data/tests/test_handler_check.rb +1 -3
- data/tests/test_hc.rb +24 -59
- data/tests/test_httpclient.rb +27 -64
- data/tests/test_httpclient2.rb +1 -29
- data/tests/test_inactivity_timeout.rb +44 -40
- data/tests/test_kb.rb +26 -52
- data/tests/test_ltp.rb +23 -67
- data/tests/test_ltp2.rb +1 -30
- data/tests/test_next_tick.rb +1 -30
- data/tests/test_object_protocol.rb +8 -9
- data/tests/test_pause.rb +45 -37
- data/tests/test_pending_connect_timeout.rb +42 -38
- data/tests/test_process_watch.rb +1 -3
- data/tests/test_processes.rb +92 -110
- data/tests/test_proxy_connection.rb +128 -104
- data/tests/test_pure.rb +29 -75
- data/tests/test_queue.rb +2 -4
- data/tests/test_resolver.rb +55 -0
- data/tests/test_running.rb +1 -29
- data/tests/test_sasl.rb +7 -32
- data/tests/test_send_file.rb +162 -196
- data/tests/test_servers.rb +13 -56
- data/tests/test_smtpclient.rb +1 -29
- data/tests/test_smtpserver.rb +1 -29
- data/tests/test_spawn.rb +2 -31
- data/tests/test_ssl_args.rb +9 -10
- data/tests/test_ssl_methods.rb +1 -3
- data/tests/test_ssl_verify.rb +63 -63
- data/tests/test_tick_loop.rb +1 -1
- data/tests/test_timers.rb +52 -89
- data/tests/test_ud.rb +1 -29
- metadata +20 -10
- data/setup.rb +0 -1585
- data/tests/test_errors.rb +0 -82
- data/tests/testem.rb +0 -31
data/tests/test_running.rb
CHANGED
@@ -1,32 +1,4 @@
|
|
1
|
-
|
2
|
-
#
|
3
|
-
# Author:: Francis Cianfrocca (gmail: blackhedd)
|
4
|
-
# Homepage:: http://rubyeventmachine.com
|
5
|
-
# Date:: 8 April 2006
|
6
|
-
#
|
7
|
-
# See EventMachine and EventMachine::Connection for documentation and
|
8
|
-
# usage examples.
|
9
|
-
#
|
10
|
-
#----------------------------------------------------------------------------
|
11
|
-
#
|
12
|
-
# Copyright (C) 2006-07 by Francis Cianfrocca. All Rights Reserved.
|
13
|
-
# Gmail: blackhedd
|
14
|
-
#
|
15
|
-
# This program is free software; you can redistribute it and/or modify
|
16
|
-
# it under the terms of either: 1) the GNU General Public License
|
17
|
-
# as published by the Free Software Foundation; either version 2 of the
|
18
|
-
# License, or (at your option) any later version; or 2) Ruby's License.
|
19
|
-
#
|
20
|
-
# See the file COPYING for complete licensing information.
|
21
|
-
#
|
22
|
-
#---------------------------------------------------------------------------
|
23
|
-
#
|
24
|
-
#
|
25
|
-
#
|
26
|
-
|
27
|
-
$:.unshift "../lib"
|
28
|
-
require 'eventmachine'
|
29
|
-
require 'test/unit'
|
1
|
+
require 'em_test_helper'
|
30
2
|
|
31
3
|
class TestRunning < Test::Unit::TestCase
|
32
4
|
def test_running
|
data/tests/test_sasl.rb
CHANGED
@@ -1,32 +1,4 @@
|
|
1
|
-
|
2
|
-
#
|
3
|
-
# Author:: Francis Cianfrocca (gmail: blackhedd)
|
4
|
-
# Homepage:: http://rubyeventmachine.com
|
5
|
-
# Date:: 8 April 2006
|
6
|
-
#
|
7
|
-
# See EventMachine and EventMachine::Connection for documentation and
|
8
|
-
# usage examples.
|
9
|
-
#
|
10
|
-
#----------------------------------------------------------------------------
|
11
|
-
#
|
12
|
-
# Copyright (C) 2006-07 by Francis Cianfrocca. All Rights Reserved.
|
13
|
-
# Gmail: blackhedd
|
14
|
-
#
|
15
|
-
# This program is free software; you can redistribute it and/or modify
|
16
|
-
# it under the terms of either: 1) the GNU General Public License
|
17
|
-
# as published by the Free Software Foundation; either version 2 of the
|
18
|
-
# License, or (at your option) any later version; or 2) Ruby's License.
|
19
|
-
#
|
20
|
-
# See the file COPYING for complete licensing information.
|
21
|
-
#
|
22
|
-
#---------------------------------------------------------------------------
|
23
|
-
#
|
24
|
-
#
|
25
|
-
#
|
26
|
-
|
27
|
-
$:.unshift "../lib"
|
28
|
-
require 'eventmachine'
|
29
|
-
require 'test/unit'
|
1
|
+
require 'em_test_helper'
|
30
2
|
|
31
3
|
|
32
4
|
class TestSASL < Test::Unit::TestCase
|
@@ -35,7 +7,6 @@ class TestSASL < Test::Unit::TestCase
|
|
35
7
|
# we'll use TCP so this test will work on Windows. As far as the
|
36
8
|
# protocol handlers are concerned, there's no difference.
|
37
9
|
|
38
|
-
Host,Port = "127.0.0.1",9560
|
39
10
|
TestUser,TestPsw = "someone", "password"
|
40
11
|
|
41
12
|
class SaslServer < EM::Connection
|
@@ -49,12 +20,16 @@ class TestSASL < Test::Unit::TestCase
|
|
49
20
|
include EM::Protocols::SASLauthclient
|
50
21
|
end
|
51
22
|
|
23
|
+
def setup
|
24
|
+
@port = next_port
|
25
|
+
end
|
26
|
+
|
52
27
|
def test_sasl
|
53
28
|
resp = nil
|
54
29
|
EM.run {
|
55
|
-
EM.start_server(
|
30
|
+
EM.start_server( "127.0.0.1", @port, SaslServer )
|
56
31
|
|
57
|
-
c = EM.connect(
|
32
|
+
c = EM.connect( "127.0.0.1", @port, SaslClient )
|
58
33
|
d = c.validate?( TestUser, TestPsw )
|
59
34
|
d.timeout 1
|
60
35
|
d.callback {
|
data/tests/test_send_file.rb
CHANGED
@@ -1,251 +1,217 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
# Author:: Francis Cianfrocca (gmail: blackhedd)
|
4
|
-
# Homepage:: http://rubyeventmachine.com
|
5
|
-
# Date:: 8 April 2006
|
6
|
-
#
|
7
|
-
# See EventMachine and EventMachine::Connection for documentation and
|
8
|
-
# usage examples.
|
9
|
-
#
|
10
|
-
#----------------------------------------------------------------------------
|
11
|
-
#
|
12
|
-
# Copyright (C) 2006-07 by Francis Cianfrocca. All Rights Reserved.
|
13
|
-
# Gmail: blackhedd
|
14
|
-
#
|
15
|
-
# This program is free software; you can redistribute it and/or modify
|
16
|
-
# it under the terms of either: 1) the GNU General Public License
|
17
|
-
# as published by the Free Software Foundation; either version 2 of the
|
18
|
-
# License, or (at your option) any later version; or 2) Ruby's License.
|
19
|
-
#
|
20
|
-
# See the file COPYING for complete licensing information.
|
21
|
-
#
|
22
|
-
#---------------------------------------------------------------------------
|
23
|
-
#
|
24
|
-
#
|
25
|
-
#
|
26
|
-
|
27
|
-
$:.unshift "../lib"
|
28
|
-
require 'eventmachine'
|
29
|
-
require 'socket'
|
30
|
-
require 'test/unit'
|
1
|
+
require 'em_test_helper'
|
2
|
+
require 'tempfile'
|
31
3
|
|
32
4
|
class TestSendFile < Test::Unit::TestCase
|
33
5
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
end
|
6
|
+
if EM.respond_to?(:send_file_data)
|
7
|
+
module TestModule
|
8
|
+
def initialize filename
|
9
|
+
@filename = filename
|
10
|
+
end
|
40
11
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
def receive_data(data)
|
47
|
-
@data_to.call(data) if @data_to
|
48
|
-
end
|
49
|
-
|
50
|
-
def unbind
|
51
|
-
EM.stop
|
12
|
+
def post_init
|
13
|
+
send_file_data @filename
|
14
|
+
close_connection_after_writing
|
15
|
+
end
|
52
16
|
end
|
53
|
-
end
|
54
|
-
|
55
|
-
TestHost = "0.0.0.0"
|
56
|
-
TestPort = 9055
|
57
|
-
TestFilename = "./xxxxxx"
|
58
|
-
|
59
|
-
def setup
|
60
|
-
end
|
61
17
|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
def setup_timeout(timeout = 4)
|
67
|
-
EM.schedule {
|
68
|
-
start_time = EM.current_time
|
69
|
-
EM.add_periodic_timer(0.01) {
|
70
|
-
raise "timeout" if EM.current_time - start_time >= timeout
|
71
|
-
}
|
72
|
-
}
|
73
|
-
end
|
74
|
-
|
75
|
-
def test_send_file
|
76
|
-
File.open( TestFilename, "w" ) {|f|
|
77
|
-
f << ("A" * 5000)
|
78
|
-
}
|
79
|
-
|
80
|
-
data = ''
|
18
|
+
module TestClient
|
19
|
+
def data_to(&blk)
|
20
|
+
@data_to = blk
|
21
|
+
end
|
81
22
|
|
82
|
-
|
83
|
-
|
84
|
-
|
23
|
+
def receive_data(data)
|
24
|
+
@data_to.call(data) if @data_to
|
25
|
+
end
|
85
26
|
|
86
|
-
|
87
|
-
|
27
|
+
def unbind
|
28
|
+
EM.stop
|
88
29
|
end
|
89
|
-
|
30
|
+
end
|
90
31
|
|
91
|
-
|
92
|
-
|
93
|
-
|
32
|
+
def setup
|
33
|
+
@file = Tempfile.new("em_test_file")
|
34
|
+
@filename = @file.path
|
35
|
+
@port = next_port
|
36
|
+
end
|
94
37
|
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
}
|
38
|
+
def test_send_file
|
39
|
+
File.open( @filename, "w" ) {|f|
|
40
|
+
f << ("A" * 5000)
|
41
|
+
}
|
100
42
|
|
101
|
-
|
43
|
+
data = ''
|
102
44
|
|
103
|
-
ex_class = RUBY_PLATFORM == 'java' ? NativeException : RuntimeError
|
104
|
-
assert_raises( ex_class ) {
|
105
45
|
EM.run {
|
106
|
-
EM.start_server
|
46
|
+
EM.start_server "127.0.0.1", @port, TestModule, @filename
|
107
47
|
setup_timeout
|
108
|
-
|
48
|
+
|
49
|
+
EM.connect "127.0.0.1", @port, TestClient do |c|
|
109
50
|
c.data_to { |d| data << d }
|
110
51
|
end
|
111
52
|
}
|
112
|
-
}
|
113
|
-
|
114
|
-
File.unlink TestFilename
|
115
|
-
end
|
116
53
|
|
54
|
+
assert_equal( "A" * 5000, data )
|
55
|
+
end
|
117
56
|
|
118
|
-
|
119
|
-
def
|
120
|
-
|
121
|
-
|
57
|
+
# EM::Connection#send_file_data has a strict upper limit on the filesize it will work with.
|
58
|
+
def test_send_large_file
|
59
|
+
File.open( @filename, "w" ) {|f|
|
60
|
+
f << ("A" * 1000000)
|
122
61
|
}
|
123
|
-
end
|
124
|
-
end
|
125
62
|
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
63
|
+
data = ''
|
64
|
+
|
65
|
+
assert_raises(RuntimeError) {
|
66
|
+
EM.run {
|
67
|
+
EM.start_server "127.0.0.1", @port, TestModule, @filename
|
68
|
+
setup_timeout
|
69
|
+
EM.connect "127.0.0.1", @port, TestClient do |c|
|
70
|
+
c.data_to { |d| data << d }
|
71
|
+
end
|
72
|
+
}
|
130
73
|
}
|
131
74
|
end
|
132
|
-
end
|
133
75
|
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
76
|
+
module StreamTestModule
|
77
|
+
def initialize filename
|
78
|
+
@filename = filename
|
79
|
+
end
|
138
80
|
|
139
|
-
|
81
|
+
def post_init
|
82
|
+
EM::Deferrable.future( stream_file_data(@filename)) {
|
83
|
+
close_connection_after_writing
|
84
|
+
}
|
85
|
+
end
|
86
|
+
end
|
140
87
|
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
EM.connect TestHost, TestPort, TestClient do |c|
|
145
|
-
c.data_to { |d| data << d }
|
88
|
+
module ChunkStreamTestModule
|
89
|
+
def initialize filename
|
90
|
+
@filename = filename
|
146
91
|
end
|
147
|
-
}
|
148
92
|
|
149
|
-
|
93
|
+
def post_init
|
94
|
+
EM::Deferrable.future( stream_file_data(@filename, :http_chunks=>true)) {
|
95
|
+
close_connection_after_writing
|
96
|
+
}
|
97
|
+
end
|
98
|
+
end
|
150
99
|
|
151
|
-
|
152
|
-
|
100
|
+
def test_stream_file_data
|
101
|
+
File.open( @filename, "w" ) {|f|
|
102
|
+
f << ("A" * 1000)
|
103
|
+
}
|
153
104
|
|
154
|
-
|
155
|
-
File.open( TestFilename, "w" ) {|f|
|
156
|
-
f << ("A" * 1000)
|
157
|
-
}
|
105
|
+
data = ''
|
158
106
|
|
159
|
-
|
107
|
+
EM.run {
|
108
|
+
EM.start_server "127.0.0.1", @port, StreamTestModule, @filename
|
109
|
+
setup_timeout
|
110
|
+
EM.connect "127.0.0.1", @port, TestClient do |c|
|
111
|
+
c.data_to { |d| data << d }
|
112
|
+
end
|
113
|
+
}
|
160
114
|
|
161
|
-
|
162
|
-
|
163
|
-
setup_timeout
|
164
|
-
EM.connect TestHost, TestPort, TestClient do |c|
|
165
|
-
c.data_to { |d| data << d }
|
166
|
-
end
|
167
|
-
}
|
115
|
+
assert_equal( "A" * 1000, data )
|
116
|
+
end
|
168
117
|
|
169
|
-
|
118
|
+
def test_stream_chunked_file_data
|
119
|
+
File.open( @filename, "w" ) {|f|
|
120
|
+
f << ("A" * 1000)
|
121
|
+
}
|
170
122
|
|
171
|
-
|
172
|
-
end
|
123
|
+
data = ''
|
173
124
|
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
125
|
+
EM.run {
|
126
|
+
EM.start_server "127.0.0.1", @port, ChunkStreamTestModule, @filename
|
127
|
+
setup_timeout
|
128
|
+
EM.connect "127.0.0.1", @port, TestClient do |c|
|
129
|
+
c.data_to { |d| data << d }
|
130
|
+
end
|
180
131
|
}
|
132
|
+
|
133
|
+
assert_equal( "3e8\r\n#{"A" * 1000}\r\n0\r\n\r\n", data )
|
181
134
|
end
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
EM.start_server TestHost, TestPort, BadFileTestModule
|
187
|
-
setup_timeout
|
188
|
-
EM.connect TestHost, TestPort, TestClient do |c|
|
189
|
-
c.data_to { |d| data << d }
|
135
|
+
|
136
|
+
module BadFileTestModule
|
137
|
+
def initialize filename
|
138
|
+
@filename = filename
|
190
139
|
end
|
191
|
-
}
|
192
140
|
|
193
|
-
|
194
|
-
|
141
|
+
def post_init
|
142
|
+
de = stream_file_data( @filename+".wrong" )
|
143
|
+
de.errback {|msg|
|
144
|
+
send_data msg
|
145
|
+
close_connection_after_writing
|
146
|
+
}
|
147
|
+
end
|
148
|
+
end
|
149
|
+
def test_stream_bad_file
|
150
|
+
data = ''
|
151
|
+
EM.run {
|
152
|
+
EM.start_server "127.0.0.1", @port, BadFileTestModule, @filename
|
153
|
+
setup_timeout(5)
|
154
|
+
EM.connect "127.0.0.1", @port, TestClient do |c|
|
155
|
+
c.data_to { |d| data << d }
|
156
|
+
end
|
157
|
+
}
|
195
158
|
|
196
|
-
|
197
|
-
begin
|
198
|
-
require 'fastfilereaderext'
|
199
|
-
rescue LoadError
|
200
|
-
return
|
159
|
+
assert_equal( "file not found", data )
|
201
160
|
end
|
202
|
-
|
203
|
-
|
204
|
-
}
|
161
|
+
else
|
162
|
+
warn "EM.send_file_data not implemented, skipping tests in #{__FILE__}"
|
205
163
|
|
206
|
-
|
164
|
+
# Because some rubies will complain if a TestCase class has no tests
|
165
|
+
def test_em_send_file_data_not_implemented
|
166
|
+
assert !EM.respond_to?(:send_file_data)
|
167
|
+
end
|
168
|
+
end
|
207
169
|
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
170
|
+
begin
|
171
|
+
require 'fastfilereaderext'
|
172
|
+
|
173
|
+
def test_stream_large_file_data
|
174
|
+
File.open( @filename, "w" ) {|f|
|
175
|
+
f << ("A" * 10000)
|
176
|
+
}
|
215
177
|
|
216
|
-
|
178
|
+
data = ''
|
217
179
|
|
218
|
-
|
219
|
-
|
180
|
+
EM.run {
|
181
|
+
EM.start_server "127.0.0.1", @port, StreamTestModule, @filename
|
182
|
+
setup_timeout
|
183
|
+
EM.connect "127.0.0.1", @port, TestClient do |c|
|
184
|
+
c.data_to { |d| data << d }
|
185
|
+
end
|
186
|
+
}
|
220
187
|
|
221
|
-
|
222
|
-
begin
|
223
|
-
require 'fastfilereaderext'
|
224
|
-
rescue LoadError
|
225
|
-
return
|
188
|
+
assert_equal( "A" * 10000, data )
|
226
189
|
end
|
227
|
-
File.open( TestFilename, "w" ) {|f|
|
228
|
-
f << ("A" * 100000)
|
229
|
-
}
|
230
190
|
|
231
|
-
|
191
|
+
def test_stream_large_chunked_file_data
|
192
|
+
File.open( @filename, "w" ) {|f|
|
193
|
+
f << ("A" * 100000)
|
194
|
+
}
|
232
195
|
|
233
|
-
|
234
|
-
EM.start_server TestHost, TestPort, ChunkStreamTestModule
|
235
|
-
setup_timeout
|
236
|
-
EM.connect TestHost, TestPort, TestClient do |c|
|
237
|
-
c.data_to { |d| data << d }
|
238
|
-
end
|
239
|
-
}
|
196
|
+
data = ''
|
240
197
|
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
198
|
+
EM.run {
|
199
|
+
EM.start_server "127.0.0.1", @port, ChunkStreamTestModule, @filename
|
200
|
+
setup_timeout
|
201
|
+
EM.connect "127.0.0.1", @port, TestClient do |c|
|
202
|
+
c.data_to { |d| data << d }
|
203
|
+
end
|
204
|
+
}
|
247
205
|
|
248
|
-
|
206
|
+
expected = [
|
207
|
+
"4000\r\n#{"A" * 16384}\r\n" * 6,
|
208
|
+
"6a0\r\n#{"A" * 0x6a0}\r\n",
|
209
|
+
"0\r\n\r\n"
|
210
|
+
].join
|
211
|
+
assert_equal( expected, data )
|
212
|
+
end
|
213
|
+
rescue LoadError
|
214
|
+
warn "require 'fastfilereaderext' failed, skipping tests in #{__FILE__}"
|
249
215
|
end
|
250
216
|
|
251
217
|
end
|