diff options
Diffstat (limited to 'test/net')
-rw-r--r-- | test/net/http/test_http.rb | 10 | ||||
-rw-r--r-- | test/net/http/utils.rb | 5 |
2 files changed, 9 insertions, 6 deletions
diff --git a/test/net/http/test_http.rb b/test/net/http/test_http.rb index 4867acf737..fc7bfa9806 100644 --- a/test/net/http/test_http.rb +++ b/test/net/http/test_http.rb @@ -616,7 +616,7 @@ end class TestNetHTTP_v1_2 < Test::Unit::TestCase CONFIG = { 'host' => '127.0.0.1', - 'port' => 10081, + 'port' => 0, 'proxy_host' => nil, 'proxy_port' => nil, } @@ -634,7 +634,7 @@ end class TestNetHTTP_v1_2_chunked < Test::Unit::TestCase CONFIG = { 'host' => '127.0.0.1', - 'port' => 10081, + 'port' => 0, 'proxy_host' => nil, 'proxy_port' => nil, 'chunked' => true, @@ -665,7 +665,7 @@ end class TestNetHTTPContinue < Test::Unit::TestCase CONFIG = { 'host' => '127.0.0.1', - 'port' => 10081, + 'port' => 0, 'proxy_host' => nil, 'proxy_port' => nil, 'chunked' => true, @@ -750,7 +750,7 @@ end class TestNetHTTPKeepAlive < Test::Unit::TestCase CONFIG = { 'host' => '127.0.0.1', - 'port' => 10081, + 'port' => 0, 'proxy_host' => nil, 'proxy_port' => nil, 'RequestTimeout' => 1, @@ -802,7 +802,7 @@ end class TestNetHTTPLocalBind < Test::Unit::TestCase CONFIG = { 'host' => 'localhost', - 'port' => 10081, + 'port' => 0, 'proxy_host' => nil, 'proxy_port' => nil, } diff --git a/test/net/http/utils.rb b/test/net/http/utils.rb index 07e0b9fa2d..9bea8f5474 100644 --- a/test/net/http/utils.rb +++ b/test/net/http/utils.rb @@ -19,7 +19,8 @@ module TestNetHTTPUtils end def config(key) - self.class::CONFIG[key] + @config ||= self.class::CONFIG + @config[key] end def logfile @@ -42,6 +43,7 @@ module TestNetHTTPUtils end def spawn_server + @config = self.class::CONFIG server_config = { :BindAddress => config('host'), :Port => config('port'), @@ -62,6 +64,7 @@ module TestNetHTTPUtils @server = WEBrick::HTTPServer.new(server_config) @server.mount('/', Servlet, config('chunked')) @server.start + @config['port'] = @server[:Port] if @config['port'] == 0 n_try_max = 5 begin TCPSocket.open(config('host'), config('port')).close |