From d3c75a987596a3249f0bbaa8de50b8a6046cb864 Mon Sep 17 00:00:00 2001 From: Evan Weaver Date: Sat, 31 Jan 2009 19:30:58 -0800 Subject: Mongrel.run(app, opts) --- test/unit/test_server.rb | 4 ++-- test/unit/test_threading.rb | 16 ++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) (limited to 'test') diff --git a/test/unit/test_server.rb b/test/unit/test_server.rb index a44b927..4ce728d 100644 --- a/test/unit/test_server.rb +++ b/test/unit/test_server.rb @@ -28,9 +28,9 @@ class WebServerTest < Test::Unit::TestCase @app = Rack::URLMap.new('/test' => @tester) redirect_test_io do # We set max_queued_threads=1 so that we can test the reaping code - @server = HttpServer.new("127.0.0.1", @port, @app, :max_queued_threads => 1) + @server = HttpServer.new(@app, :Host => "127.0.0.1", :Port => @port, :Max_queued_threads => 1) end - @server.start! + @server.start end def teardown diff --git a/test/unit/test_threading.rb b/test/unit/test_threading.rb index 21f6c42..d4ad683 100644 --- a/test/unit/test_threading.rb +++ b/test/unit/test_threading.rb @@ -5,10 +5,10 @@ include Mongrel class FakeHandler @@concurrent_threads = 0 - @@max_concurrent_threads = 0 + @@threads = 0 def self.max_concurrent_threads - @@max_concurrent_threads ||= 0 + @@threads ||= 0 end def initialize @@ -19,7 +19,7 @@ class FakeHandler def call(env) @@mutex.synchronize do @@concurrent_threads += 1 # !!! same for += and -= - @@max_concurrent_threads = [@@concurrent_threads, @@max_concurrent_threads].max + @@threads = [@@concurrent_threads, @@threads].max end sleep(0.1) @@ -34,9 +34,9 @@ class ThreadingTest < Test::Unit::TestCase @valid_request = "GET / HTTP/1.1\r\nHost: www.google.com\r\nContent-Type: text/plain\r\n\r\n" @port = process_based_port @app = Rack::URLMap.new('/test' => FakeHandler.new) - @max_concurrent_threads = 4 - redirect_test_io { @server = HttpServer.new("127.0.0.1", @port, @app, :max_concurrent_threads => @max_concurrent_threads) } - redirect_test_io { @server.start! } + @threads = 4 + redirect_test_io { @server = HttpServer.new(@app, :Host => "127.0.0.1", :Port => @port, :Max_concurrent_threads => @threads) } + redirect_test_io { @server.start } end def teardown @@ -45,7 +45,7 @@ class ThreadingTest < Test::Unit::TestCase def test_server_respects_max_concurrent_threads_option threads = [] - (@max_concurrent_threads * 3).times do + (@threads * 3).times do threads << Thread.new do send_data_over_socket("GET /test HTTP/1.1\r\nHost: localhost\r\nContent-Type: text/plain\r\n\r\n") end @@ -53,7 +53,7 @@ class ThreadingTest < Test::Unit::TestCase while threads.any? { |thread| thread.alive? } sleep(0) end - assert_equal @max_concurrent_threads, FakeHandler.max_concurrent_threads + assert_equal @threads, FakeHandler.max_concurrent_threads end private -- cgit v1.2.3-24-ge0c7