summaryrefslogtreecommitdiff
path: root/test/webrick/test_server.rb
diff options
context:
space:
mode:
Diffstat (limited to 'test/webrick/test_server.rb')
-rw-r--r--test/webrick/test_server.rb30
1 files changed, 16 insertions, 14 deletions
diff --git a/test/webrick/test_server.rb b/test/webrick/test_server.rb
index 3f849a4..40afdb0 100644
--- a/test/webrick/test_server.rb
+++ b/test/webrick/test_server.rb
@@ -25,27 +25,29 @@ class TestWEBrickServer < Test::Unit::TestCase
def test_start_exception
stopped = 0
- config = {
- :StopCallback => Proc.new{ stopped += 1 },
- }
-
- assert_raises(SignalException) do
- TestWEBrick.start_server(Echo, config) { |server, addr, port, log|
- listener = server.listeners.first
- def listener.accept
- raise SignalException, 'SIGTERM' # simulate signal in main thread
- end
+ log = StringIO.new('')
+ logger = WEBrick::Log.new(log, WEBrick::BasicLog::WARN)
- Thread.pass while server.status != :Running
+ assert_raises(SignalException) do
+ listener = Object.new
+ def listener.to_io # IO.select invokes #to_io.
+ raise SignalException, 'SIGTERM' # simulate signal in main thread
+ end
- TCPSocket.open(addr, port) { |sock| sock << "foo\n" }
+ server = WEBrick::HTTPServer.new({
+ :BindAddress => "127.0.0.1", :Port => 0,
+ :StopCallback => Proc.new{ stopped += 1 },
+ :Logger => logger,
+ })
+ server.listeners[0].close
+ server.listeners[0] = listener
- Thread.pass until server.status == :Stop
- }
+ server.start
end
assert_equal(stopped, 1)
+ assert_match(/FATAL SignalException: SIGTERM/, log.string)
end
def test_callbacks