diff --git a/test/net/http/test_http.rb b/test/net/http/test_http.rb index 660c0ff..2d81668 100644 --- a/test/net/http/test_http.rb +++ b/test/net/http/test_http.rb @@ -426,7 +426,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, } @@ -444,7 +444,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, @@ -476,7 +476,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, diff --git a/test/net/http/test_https.rb b/test/net/http/test_https.rb index 983ba7f..2f2c699 100644 --- a/test/net/http/test_https.rb +++ b/test/net/http/test_https.rb @@ -24,7 +24,7 @@ class TestNetHTTPS < Test::Unit::TestCase CONFIG = { 'host' => '127.0.0.1', - 'port' => 10082, # different from test_http.rb + 'port' => 0, 'proxy_host' => nil, 'proxy_port' => nil, 'ssl_enable' => true, diff --git a/test/net/http/utils.rb b/test/net/http/utils.rb index 50f616f..db01b18 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'), @@ -61,6 +63,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