summaryrefslogtreecommitdiff
path: root/test/open-uri
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-11-09 11:51:06 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-11-09 11:51:06 +0000
commit070c310e87d04865da1b4f217432e22cfae5e380 (patch)
treed11d9ef6c67b447bc886182b9c02e38aa70a3a00 /test/open-uri
parent9b559f194c9960e66011b8f40d428fe36cb302be (diff)
* test/webrick: Store log in an array.
* test/net/http: Ditto. * test/open-uri: Ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48341 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/open-uri')
-rw-r--r--test/open-uri/test_open-uri.rb13
-rw-r--r--test/open-uri/test_ssl.rb23
2 files changed, 21 insertions, 15 deletions
diff --git a/test/open-uri/test_open-uri.rb b/test/open-uri/test_open-uri.rb
index 816d7fa..d2d8840 100644
--- a/test/open-uri/test_open-uri.rb
+++ b/test/open-uri/test_open-uri.rb
@@ -14,7 +14,7 @@ class TestOpenURI < Test::Unit::TestCase
end
def with_http(log_is_empty=true)
- log = StringIO.new('')
+ log = []
logger = WEBrick::Log.new(log, WEBrick::BasicLog::WARN)
Dir.mktmpdir {|dr|
srv = WEBrick::HTTPServer.new({
@@ -34,7 +34,7 @@ class TestOpenURI < Test::Unit::TestCase
end
}
if log_is_empty
- assert_equal("", log.string)
+ assert_equal([], log)
end
end
@@ -92,7 +92,8 @@ class TestOpenURI < Test::Unit::TestCase
}
server_thread2 = Thread.new {
server_thread.join
- assert_match(%r{ERROR `/not-exist' not found}, server_log.string)
+ assert_equal(1, server_log.length)
+ assert_match(%r{ERROR `/not-exist' not found}, server_log[0])
}
assert_join_threads([client_thread, server_thread2])
}
@@ -486,7 +487,8 @@ class TestOpenURI < Test::Unit::TestCase
}
server_thread2 = Thread.new {
server_thread.join
- assert_match(/ERROR WEBrick::HTTPStatus::Unauthorized/, server_log.string)
+ assert_equal(1, server_log.length)
+ assert_match(/ERROR WEBrick::HTTPStatus::Unauthorized/, server_log[0])
}
assert_join_threads([client_thread, server_thread2])
}
@@ -505,7 +507,8 @@ class TestOpenURI < Test::Unit::TestCase
}
server_thread2 = Thread.new {
server_thread.join
- assert_match(/ERROR WEBrick::HTTPStatus::Unauthorized/, server_log.string)
+ assert_equal(1, server_log.length)
+ assert_match(/ERROR WEBrick::HTTPStatus::Unauthorized/, server_log[0])
}
assert_join_threads([client_thread, server_thread2])
}
diff --git a/test/open-uri/test_ssl.rb b/test/open-uri/test_ssl.rb
index baffd1c..154bcf4 100644
--- a/test/open-uri/test_ssl.rb
+++ b/test/open-uri/test_ssl.rb
@@ -19,7 +19,7 @@ class TestOpenURISSL
end
def with_https(log_is_empty=true)
- log = StringIO.new('')
+ log = []
logger = WEBrick::Log.new(log, WEBrick::BasicLog::WARN)
Dir.mktmpdir {|dr|
srv = WEBrick::HTTPServer.new({
@@ -42,7 +42,7 @@ class TestOpenURISSL
th.join
end
if log_is_empty
- assert_equal("", log.string)
+ assert_equal([], log)
end
}
end
@@ -96,14 +96,15 @@ class TestOpenURISSL
}
server_thread2 = Thread.new {
server_thread.join
- assert_match(/ERROR OpenSSL::SSL::SSLError:/, server_log.string)
+ assert_equal(1, server_log.length)
+ assert_match(/ERROR OpenSSL::SSL::SSLError:/, server_log[0])
}
assert_join_threads([client_thread, server_thread2])
}
end
def with_https_proxy
- proxy_log = StringIO.new('')
+ proxy_log = []
proxy_logger = WEBrick::Log.new(proxy_log, WEBrick::BasicLog::WARN)
with_https {|srv, dr, url, server_thread, server_log|
srv.mount_proc("/proxy", lambda { |req, res| res.body = "proxy" } )
@@ -116,7 +117,7 @@ class TestOpenURISSL
proxy = WEBrick::HTTPProxyServer.new({
:ServerType => Thread,
:Logger => proxy_logger,
- :AccessLog => [[proxy_access_log=StringIO.new, WEBrick::AccessLog::COMMON_LOG_FORMAT]],
+ :AccessLog => [[proxy_access_log=[], WEBrick::AccessLog::COMMON_LOG_FORMAT]],
:BindAddress => '127.0.0.1',
:Port => 0})
_, proxy_port, _, proxy_host = proxy.listeners[0].addr
@@ -128,7 +129,7 @@ class TestOpenURISSL
proxy_thread.join
end
}
- assert_equal('', proxy_log.string)
+ assert_equal([], proxy_log)
end
def test_proxy_cacert_file
@@ -146,8 +147,9 @@ class TestOpenURISSL
}
proxy_thread2 = Thread.new {
proxy_thread.join
- assert_match(%r[CONNECT #{url.sub(%r{\Ahttps://}, '')} ], proxy_access_log.string)
- assert_equal('', proxy_log.string)
+ assert_equal(1, proxy_access_log.length)
+ assert_match(%r[CONNECT #{url.sub(%r{\Ahttps://}, '')} ], proxy_access_log[0])
+ assert_equal([], proxy_log)
}
assert_join_threads([client_thread, proxy_thread2, server_thread])
}
@@ -168,8 +170,9 @@ class TestOpenURISSL
}
proxy_thread2 = Thread.new {
proxy_thread.join
- assert_match(%r[CONNECT #{url.sub(%r{\Ahttps://}, '')} ], proxy_access_log.string)
- assert_equal('', proxy_log.string)
+ assert_equal(1, proxy_access_log.length)
+ assert_match(%r[CONNECT #{url.sub(%r{\Ahttps://}, '')} ], proxy_access_log[0])
+ assert_equal([], proxy_log)
}
assert_join_threads([client_thread, proxy_thread2, server_thread])
}