mirror of https://github.com/apache/lucene.git
Add tests to cover the exception handling, bringing code coverage back to 100%
git-svn-id: https://svn.apache.org/repos/asf/incubator/solr/trunk@495258 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
0cad261fb8
commit
2d5f7d6250
|
@ -16,10 +16,26 @@ require 'solr'
|
|||
class TestServer < Test::Unit::TestCase
|
||||
include Solr
|
||||
|
||||
class BadRequest < Request
|
||||
def initialize
|
||||
@url_path = "/bogus"
|
||||
end
|
||||
|
||||
def to_http_body
|
||||
"bogus"
|
||||
end
|
||||
end
|
||||
|
||||
def setup
|
||||
@connection = Connection.new("http://localhost:8888")
|
||||
end
|
||||
|
||||
def test_error
|
||||
assert_raise(Net::HTTPServerException) do
|
||||
@connection.send(BadRequest.new)
|
||||
end
|
||||
end
|
||||
|
||||
def test_commit
|
||||
response = @connection.send(UpdateRequest.new("<commit/>"))
|
||||
assert_equal "<result status=\"0\"></result>", response.raw_response
|
||||
|
|
|
@ -39,6 +39,14 @@ class RequestTest < Test::Unit::TestCase
|
|||
assert_raise(Solr::RequestException) do
|
||||
new Solr::Response.new("<result status=\"400\">ERROR:</result>")
|
||||
end
|
||||
|
||||
begin
|
||||
new Solr::Response.new("<result status=\"400\">ERROR:</result>")
|
||||
rescue Solr::RequestException => exception
|
||||
assert_equal "ERROR:", exception.message
|
||||
assert_equal exception.message, exception.to_s
|
||||
assert_equal "400", exception.code
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue