From 638620f70d8f9056b56fc9e8dc97da83804efcf1 Mon Sep 17 00:00:00 2001 From: evanweaver Date: Sun, 21 Oct 2007 00:49:39 +0000 Subject: [PATCH] don't use #close_write anymore git-svn-id: svn+ssh://rubyforge.org/var/svn/mongrel/trunk@708 19e92222-5c0b-0410-8929-a290d50e31e9 --- test/jruby_socket.rb | 12 +++++------- test/test_ws.rb | 18 ++++++++---------- 2 files changed, 13 insertions(+), 17 deletions(-) diff --git a/test/jruby_socket.rb b/test/jruby_socket.rb index bc905c90..08e792cf 100644 --- a/test/jruby_socket.rb +++ b/test/jruby_socket.rb @@ -1,10 +1,8 @@ # Minimal test to help debug JRuby socket issues -require 'mongrel' - -include Mongrel - -@server = HttpServer.new("127.0.0.1", 9997, num_processors=1) -@server.run -@server.stop(true) +require 'socket' +socket = TCPSocket.new('127.0.0.1', '3000') +socket.write("G") +socket.close_write +socket.write("E") diff --git a/test/test_ws.rb b/test/test_ws.rb index a3f2462c..67066311 100644 --- a/test/test_ws.rb +++ b/test/test_ws.rb @@ -33,7 +33,9 @@ class WebServerTest < Test::Unit::TestCase end def teardown - @server.stop(true) + redirect_test_io do + @server.stop(true) + end end def test_simple_server @@ -43,24 +45,20 @@ class WebServerTest < Test::Unit::TestCase def do_test(string, chunk, close_after=nil) - socket = TCPSocket.new("127.0.0.1", 9998); + @socket = TCPSocket.new("127.0.0.1", 9998); request = StringIO.new(string) chunks_out = 0 while data = request.read(chunk) - chunks_out += socket.write(data) - puts "Chunks: #{chunks_out.inspect}" - socket.flush + chunks_out += @socket.write(data) + @socket.flush sleep 0.2 if close_after and chunks_out > close_after - puts "** Closing write" - socket.close_write + @socket.close sleep 1 end end - socket.write(" ") if RUBY_PLATFORM =~ /mingw|mswin|cygwin/ - socket.close - puts "** Closing entire socket" + @socket.write(" ") # Some platforms only raise the exception on attempted write end def test_trickle_attack