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