* test/webrick/test_cgi.rb: Removes usage of deprecated

:RequestHandler option.
  patched by Peter Weldon [ruby-core:34010]

* test/webrick/test_httpproxy.rb: ditto.

* test/webrick/test_httpserver.rb: Add a test of the deprecation
  behaviour.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30516 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
naruse 2011-01-12 00:37:12 +00:00
Родитель 23733f1014
Коммит 6bcf709838
4 изменённых файлов: 35 добавлений и 6 удалений

Просмотреть файл

@ -1,3 +1,14 @@
Wed Jan 12 03:59:36 2011 NARUSE, Yui <naruse@ruby-lang.org>
* test/webrick/test_cgi.rb: Removes usage of deprecated
:RequestHandler option.
patched by Peter Weldon [ruby-core:34010]
* test/webrick/test_httpproxy.rb: ditto.
* test/webrick/test_httpserver.rb: Add a test of the deprecation
behaviour.
Wed Jan 12 08:37:07 2011 Nobuyoshi Nakada <nobu@ruby-lang.org>
* hash.c (hash_i): return different values for inverse hash.

Просмотреть файл

@ -10,7 +10,7 @@ class TestWEBrickCGI < Test::Unit::TestCase
:CGIInterpreter => TestWEBrick::RubyBin,
:DocumentRoot => File.dirname(__FILE__),
:DirectoryIndex => ["webrick.cgi"],
:RequestHandler => Proc.new{|req, res|
:RequestCallback => Proc.new{|req, res|
def req.meta_vars
meta = super
meta["RUBYLIB"] = $:.join(File::PATH_SEPARATOR)

Просмотреть файл

@ -33,7 +33,7 @@ class TestWEBrickHTTPProxy < Test::Unit::TestCase
config = {
:ServerName => "localhost.localdomain",
:ProxyContentHandler => Proc.new{|req, res| proxy_handler_called += 1 },
:RequestHandler => Proc.new{|req, res| request_handler_called += 1 }
:RequestCallback => Proc.new{|req, res| request_handler_called += 1 }
}
TestWEBrick.start_httpproxy(config){|server, addr, port, log|
server.mount_proc("/"){|req, res|
@ -78,7 +78,7 @@ class TestWEBrickHTTPProxy < Test::Unit::TestCase
config = {
:ServerName => "localhost.localdomain",
:ProxyContentHandler => Proc.new{|req, res| proxy_handler_called += 1 },
:RequestHandler => Proc.new{|req, res| request_handler_called += 1 }
:RequestCallback => Proc.new{|req, res| request_handler_called += 1 }
}
TestWEBrick.start_httpproxy(config){|server, addr, port, log|
server.mount_proc("/"){|req, res|
@ -143,7 +143,7 @@ class TestWEBrickHTTPProxy < Test::Unit::TestCase
}
config = {
:ServerName => "localhost.localdomain",
:RequestHandler => Proc.new{|req, res|
:RequestCallback => Proc.new{|req, res|
assert_equal("CONNECT", req.request_method)
},
}
@ -185,7 +185,7 @@ class TestWEBrickHTTPProxy < Test::Unit::TestCase
up_config = {
:ServerName => "localhost.localdomain",
:ProxyContentHandler => Proc.new{|req, res| up_proxy_handler_called += 1},
:RequestHandler => Proc.new{|req, res| up_request_handler_called += 1}
:RequestCallback => Proc.new{|req, res| up_request_handler_called += 1}
}
TestWEBrick.start_httpproxy(up_config){|up_server, up_addr, up_port, up_log|
up_server.mount_proc("/"){|req, res|
@ -195,7 +195,7 @@ class TestWEBrickHTTPProxy < Test::Unit::TestCase
:ServerName => "localhost.localdomain",
:ProxyURI => URI.parse("http://localhost:#{up_port}"),
:ProxyContentHandler => Proc.new{|req, res| proxy_handler_called += 1},
:RequestHandler => Proc.new{|req, res| request_handler_called += 1},
:RequestCallback => Proc.new{|req, res| request_handler_called += 1},
}
TestWEBrick.start_httpproxy(config){|server, addr, port, log|
http = Net::HTTP.new(up_addr, up_port, addr, port)

Просмотреть файл

@ -257,4 +257,22 @@ class TestWEBrickHTTPServer < Test::Unit::TestCase
assert_equal(started, 1)
assert_equal(stopped, 1)
end
def test_request_handler_callback_is_deprecated
requested = 0
config = {
:ServerName => "localhost",
:RequestHandler => Proc.new{|req, res| requested += 1 },
}
TestWEBrick.start_httpserver(config){|server, addr, port, log|
true while server.status != :Running
http = Net::HTTP.new(addr, port)
req = Net::HTTP::Get.new("/")
req["Host"] = "localhost:#{port}"
http.request(req){|res| assert_equal("404", res.code, log.call)}
assert_match(%r{:RequestHandler is deprecated, please use :RequestCallback$}, log.call, log.call)
}
assert_equal(requested, 1)
end
end