eventmachine 0.12.0 → 0.12.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,4 +1,4 @@
1
- # $Id: test_httpclient.rb 668 2008-01-04 23:00:34Z blackhedd $
1
+ # $Id: test_httpclient.rb 786 2008-09-16 07:33:27Z francis $
2
2
  #
3
3
  # Author:: Francis Cianfrocca (gmail: blackhedd)
4
4
  # Homepage:: http://rubyeventmachine.com
@@ -112,6 +112,7 @@ class TestHttpClient < Test::Unit::TestCase
112
112
  assert ok
113
113
  end
114
114
 
115
+
115
116
  #---------------------------------------
116
117
 
117
118
  class PostContent < EventMachine::Protocols::LineAndTextProtocol
@@ -189,6 +190,26 @@ class TestHttpClient < Test::Unit::TestCase
189
190
  assert ok
190
191
  end
191
192
 
193
+
194
+
195
+ # We can tell the client to send an HTTP/1.0 request (default is 1.1).
196
+ # This is useful for suppressing chunked responses until those are working.
197
+ def test_version_1_0
198
+ ok = false
199
+ EM.run {
200
+ c = EM::P::HttpClient.request :host => "www.bayshorenetworks.com",
201
+ :port => 80,
202
+ :version => "1.0"
203
+ c.callback {|result|
204
+ ok = true;
205
+ EventMachine.stop
206
+ }
207
+ c.errback {EventMachine.stop}
208
+ }
209
+ assert ok
210
+ end
211
+
212
+
192
213
  end
193
214
 
194
215
 
@@ -1,4 +1,4 @@
1
- # $Id: test_ltp2.rb 668 2008-01-04 23:00:34Z blackhedd $
1
+ # $Id: test_ltp2.rb 725 2008-06-29 23:04:48Z francis $
2
2
  #
3
3
  # Author:: Francis Cianfrocca (gmail: blackhedd)
4
4
  # Homepage:: http://rubyeventmachine.com
@@ -257,5 +257,64 @@ Line 4
257
257
  assert_equal( "0" * 500, a.data )
258
258
  end
259
259
 
260
+
261
+
262
+ # Test an end-of-binary call. Arrange to receive binary data but don't bother counting it
263
+ # as it comes. Rely on getting receive_end_of_binary_data to signal the transition back to
264
+ # line mode.
265
+ # At the present time, this isn't strictly necessary with sized binary chunks because by
266
+ # definition we accumulate them and make exactly one call to receive_binary_data, but
267
+ # we may want to support a mode in the future that would break up large chunks into multiple
268
+ # calls.
269
+ class LazyBinary
270
+ include EM::Protocols::LineText2
271
+ attr_reader :data, :end
272
+ def initialize *args
273
+ super
274
+ @data = ""
275
+ set_text_mode 1000
276
+ end
277
+ def receive_binary_data data
278
+ # we expect to get all the data in one chunk, even in the byte-by-byte case,
279
+ # because sized transfers by definition give us exactly one call to
280
+ # #receive_binary_data.
281
+ @data = data
282
+ end
283
+ def receive_end_of_binary_data
284
+ @end = true
285
+ end
286
+ end
287
+ def test_receive_end_of_binary_data
288
+ testdata = "_" * 1000
289
+ a = LazyBinary.new
290
+ testdata.length.times {|i| a.receive_data( testdata[i...i+1] ) }
291
+ assert_equal( "_" * 1000, a.data )
292
+ assert( a.end )
293
+ end
294
+
295
+
296
+ # This tests a bug fix in which calling set_text_mode failed when called
297
+ # inside receive_binary_data.
298
+ #
299
+ class BinaryPair
300
+ include EM::Protocols::LineText2
301
+ attr_reader :sizes
302
+ def initialize *args
303
+ super
304
+ set_text_mode 1
305
+ @sizes = []
306
+ end
307
+ def receive_binary_data dt
308
+ @sizes << dt.length
309
+ set_text_mode( (dt.length == 1) ? 2 : 1 )
310
+ end
311
+ end
312
+ def test_binary_pairs
313
+ test_data = "123" * 5
314
+ a = BinaryPair.new
315
+ a.receive_data test_data
316
+ assert_equal( [1,2,1,2,1,2,1,2,1,2], a.sizes )
317
+ end
318
+
260
319
  end
261
320
 
@@ -1,4 +1,4 @@
1
- # $Id: test_next_tick.rb 668 2008-01-04 23:00:34Z blackhedd $
1
+ # $Id: test_next_tick.rb 697 2008-06-15 22:00:00Z francis $
2
2
  #
3
3
  # Author:: Francis Cianfrocca (gmail: blackhedd)
4
4
  # Homepage:: http://rubyeventmachine.com
@@ -55,4 +55,48 @@ class TestNextTick < Test::Unit::TestCase
55
55
  }
56
56
  assert true
57
57
  end
58
+
59
+ # This illustrates the solution to a long-standing problem.
60
+ # It's now possible to correctly nest calls to EM#run.
61
+ # See the source code commentary for EM#run for more info.
62
+ #
63
+ def test_run_run
64
+ EM.run {
65
+ EM.run {
66
+ EM.next_tick {EM.stop}
67
+ }
68
+ }
69
+ end
70
+
71
+ # We now support an additional parameter for EM#run.
72
+ # You can pass two procs to EM#run now. The first is executed as the normal
73
+ # run block. The second (if given) is scheduled for execution after the
74
+ # reactor loop completes.
75
+ # The reason for supporting this is subtle. There has always been an expectation
76
+ # that EM#run doesn't return until after the reactor loop ends. But now it's
77
+ # possible to nest calls to EM#run, which means that a nested call WILL
78
+ # RETURN. In order to write code that will run correctly either way, it's
79
+ # recommended to put any code which must execute after the reactor completes
80
+ # in the second parameter.
81
+ #
82
+ def test_run_run_2
83
+ a = proc {EM.stop}
84
+ b = proc {assert true}
85
+ EM.run a, b
86
+ end
87
+
88
+
89
+ # This illustrates that EM#run returns when it's called nested.
90
+ # This isn't a feature, rather it's something to be wary of when writing code
91
+ # that must run correctly even if EM#run is called while a reactor is already
92
+ # running.
93
+ def test_run_run_3
94
+ a = []
95
+ EM.run {
96
+ EM.run proc {EM.stop}, proc {a << 2}
97
+ a << 1
98
+ }
99
+ assert_equal( [1,2], a )
100
+ end
101
+
58
102
  end
@@ -1,4 +1,4 @@
1
- # $Id: test_sasl.rb 668 2008-01-04 23:00:34Z blackhedd $
1
+ # $Id: test_sasl.rb 720 2008-06-20 23:50:59Z francis $
2
2
  #
3
3
  # Author:: Francis Cianfrocca (gmail: blackhedd)
4
4
  # Homepage:: http://rubyeventmachine.com
@@ -57,6 +57,7 @@ class TestSASL < Test::Unit::TestCase
57
57
 
58
58
  c = EM.connect( Host, Port, SaslClient )
59
59
  d = c.validate?( TestUser, TestPsw )
60
+ d.timeout 2
60
61
  d.callback {
61
62
  resp = true
62
63
  EM.stop
@@ -1,4 +1,4 @@
1
- # $Id: test_timers.rb 668 2008-01-04 23:00:34Z blackhedd $
1
+ # $Id: test_timers.rb 715 2008-06-20 21:26:14Z francis $
2
2
  #
3
3
  # Author:: Francis Cianfrocca (gmail: blackhedd)
4
4
  # Homepage:: http://rubyeventmachine.com
@@ -107,7 +107,7 @@ class TestTimers < Test::Unit::TestCase
107
107
 
108
108
 
109
109
  # This test is only applicable to compiled versions of the reactor.
110
- # Pure ruby versions have no built-in limit on the number of outstanding timers.
110
+ # Pure ruby and java versions have no built-in limit on the number of outstanding timers.
111
111
  #
112
112
  def test_timer_change_max_outstanding
113
113
  ten_thousand_timers = proc {
@@ -118,6 +118,8 @@ class TestTimers < Test::Unit::TestCase
118
118
  EM.run {
119
119
  if EM.library_type == :pure_ruby
120
120
  ten_thousand_timers.call
121
+ elsif EM.library_type == :java
122
+ ten_thousand_timers.call
121
123
  else
122
124
  assert_raise( RuntimeError ) {
123
125
  ten_thousand_timers.call
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eventmachine
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.0
4
+ version: 0.12.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Francis Cianfrocca
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-06-03 00:00:00 -04:00
12
+ date: 2008-09-25 00:00:00 +01:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -34,90 +34,92 @@ extra_rdoc_files:
34
34
  - SPAWNED_PROCESSES
35
35
  - DEFERRABLES
36
36
  files:
37
+ - tests/test_attach.rb
38
+ - tests/test_basic.rb
39
+ - tests/test_defer.rb
40
+ - tests/test_epoll.rb
37
41
  - tests/test_errors.rb
38
- - tests/test_spawn.rb
42
+ - tests/test_eventables.rb
43
+ - tests/test_exc.rb
44
+ - tests/test_futures.rb
45
+ - tests/test_hc.rb
46
+ - tests/test_httpclient.rb
39
47
  - tests/test_httpclient2.rb
40
48
  - tests/test_kb.rb
49
+ - tests/test_ltp.rb
41
50
  - tests/test_ltp2.rb
42
51
  - tests/test_next_tick.rb
43
- - tests/test_send_file.rb
44
- - tests/test_futures.rb
52
+ - tests/test_processes.rb
53
+ - tests/test_pure.rb
54
+ - tests/test_running.rb
45
55
  - tests/test_sasl.rb
46
- - tests/test_defer.rb
47
- - tests/test_timers.rb
56
+ - tests/test_send_file.rb
57
+ - tests/test_servers.rb
48
58
  - tests/test_smtpclient.rb
49
- - tests/test_ltp.rb
50
- - tests/test_processes.rb
59
+ - tests/test_smtpserver.rb
60
+ - tests/test_spawn.rb
61
+ - tests/test_timers.rb
51
62
  - tests/test_ud.rb
52
- - tests/test_servers.rb
53
- - tests/test_running.rb
54
- - tests/test_exc.rb
55
- - tests/test_pure.rb
56
- - tests/test_basic.rb
57
- - tests/test_eventables.rb
58
- - tests/test_epoll.rb
59
63
  - tests/testem.rb
60
- - tests/test_hc.rb
61
- - tests/test_httpclient.rb
62
- - tests/test_smtpserver.rb
63
- - lib/jeventmachine.rb
64
+ - lib/em
65
+ - lib/em/deferrable.rb
66
+ - lib/em/eventable.rb
67
+ - lib/em/future.rb
68
+ - lib/em/messages.rb
69
+ - lib/em/processes.rb
70
+ - lib/em/spawnable.rb
71
+ - lib/em/streamer.rb
64
72
  - lib/eventmachine.rb
73
+ - lib/eventmachine_version.rb
65
74
  - lib/evma
66
- - lib/evma/reactor.rb
67
- - lib/evma/factory.rb
68
75
  - lib/evma/callback.rb
69
76
  - lib/evma/container.rb
77
+ - lib/evma/factory.rb
70
78
  - lib/evma/protocol.rb
79
+ - lib/evma/reactor.rb
80
+ - lib/evma.rb
81
+ - lib/jeventmachine.rb
82
+ - lib/pr_eventmachine.rb
71
83
  - lib/protocols
72
- - lib/protocols/tcptest.rb
73
- - lib/protocols/httpcli2.rb
74
- - lib/protocols/header_and_content.rb
75
- - lib/protocols/saslauth.rb
76
- - lib/protocols/stomp.rb
77
- - lib/protocols/linetext2.rb
78
- - lib/protocols/smtpserver.rb
79
- - lib/protocols/line_and_text.rb
80
84
  - lib/protocols/buftok.rb
85
+ - lib/protocols/header_and_content.rb
86
+ - lib/protocols/httpcli2.rb
81
87
  - lib/protocols/httpclient.rb
88
+ - lib/protocols/line_and_text.rb
89
+ - lib/protocols/linetext2.rb
90
+ - lib/protocols/postgres.rb
91
+ - lib/protocols/saslauth.rb
82
92
  - lib/protocols/smtpclient.rb
83
- - lib/pr_eventmachine.rb
84
- - lib/eventmachine_version.rb
85
- - lib/em
86
- - lib/em/messages.rb
87
- - lib/em/streamer.rb
88
- - lib/em/eventable.rb
89
- - lib/em/processes.rb
90
- - lib/em/deferrable.rb
91
- - lib/em/future.rb
92
- - lib/em/spawnable.rb
93
- - lib/evma.rb
94
- - ext/cmain.cpp
95
- - ext/eventmachine_cpp.h
93
+ - lib/protocols/smtpserver.rb
94
+ - lib/protocols/stomp.rb
95
+ - lib/protocols/tcptest.rb
96
+ - ext/binder.cpp
96
97
  - ext/binder.h
97
- - ext/sigs.cpp
98
- - ext/eventmachine.h
99
- - ext/sigs.h
98
+ - ext/cmain.cpp
99
+ - ext/cplusplus.cpp
100
100
  - ext/ed.cpp
101
+ - ext/ed.h
101
102
  - ext/em.cpp
103
+ - ext/em.h
104
+ - ext/emwin.cpp
105
+ - ext/emwin.h
106
+ - ext/epoll.cpp
107
+ - ext/epoll.h
108
+ - ext/eventmachine.h
109
+ - ext/eventmachine_cpp.h
110
+ - ext/extconf.rb
111
+ - ext/files.cpp
112
+ - ext/files.h
113
+ - ext/kb.cpp
102
114
  - ext/page.cpp
103
- - ext/ssl.h
104
115
  - ext/page.h
116
+ - ext/pipe.cpp
105
117
  - ext/project.h
106
- - ext/epoll.h
107
- - ext/binder.cpp
108
- - ext/ed.h
109
- - ext/epoll.cpp
110
- - ext/files.h
111
- - ext/cplusplus.cpp
112
- - ext/emwin.cpp
113
- - ext/em.h
114
118
  - ext/rubymain.cpp
115
- - ext/pipe.cpp
116
- - ext/files.cpp
119
+ - ext/sigs.cpp
120
+ - ext/sigs.h
117
121
  - ext/ssl.cpp
118
- - ext/extconf.rb
119
- - ext/kb.cpp
120
- - ext/emwin.h
122
+ - ext/ssl.h
121
123
  - README
122
124
  - RELEASE_NOTES
123
125
  - COPYING
@@ -157,7 +159,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
157
159
  requirements: []
158
160
 
159
161
  rubyforge_project: eventmachine
160
- rubygems_version: 1.0.1
162
+ rubygems_version: 1.2.0
161
163
  signing_key:
162
164
  specification_version: 2
163
165
  summary: Ruby/EventMachine library