test/test_evdispatch.rb in evdispatch-0.2.6 vs test/test_evdispatch.rb in evdispatch-0.3.0
- old
+ new
@@ -1,9 +1,38 @@
require File.dirname(__FILE__) + '/test_helper.rb'
class TestEvdispatch < Test::Unit::TestCase
- def test_object_test
+ def test_streaming
+ d = Evdispatch::Loop.new
+ d.start
+
+ count = 10000
+
+ streams = []
+ # create 100 streams
+ 100.times do|i|
+ stream = d.request("http://127.0.0.1:4044/bytes/#{count}", :stream => true )
+ streams << stream
+ end
+
+ # TODO: we should expose the pipe so someone can select on ready responses
+ for stream in streams do
+ res = stream.read
+ res = stream.read until res == 0
+
+ assert_equal( 0, res )
+ assert_equal( "C"*count, stream.body )
+ headers = stream.headers
+ assert_match( "Content-Length: 10000", headers )
+ assert_match( "Content-Type: text/json", headers )
+ assert_match( "HTTP/1.1 200 OK", headers )
+ end
+
+ d.stop
+ end
+
+ def test_object_allocation
d = Evdispatch::Loop.new
# start the event loop thread
d.start