a test of Solrs ruby escaping, mainly as a real example of adding a document and then searching for it

git-svn-id: https://svn.apache.org/repos/asf/incubator/solr/trunk@494208 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Erik Hatcher 2007-01-08 21:50:30 +00:00
parent c10a85f982
commit e6467d8838
2 changed files with 22 additions and 4 deletions

View File

@ -55,8 +55,8 @@ module Solr
private
def field(name, value)
field = REXML::Element.new("field")
field.add_attribute("name", name)
field.add_text(value)
field.add_attribute("name", name.to_s)
field.add_text(value.to_s)
field
end

View File

@ -15,10 +15,28 @@ require 'solr'
class TestServer < Test::Unit::TestCase
include Solr
def setup
@connection = Connection.new("http://localhost:8888")
end
def test_commit
connection = Connection.new("http://localhost:8888")
response = connection.send(UpdateRequest.new("<commit/>"))
response = @connection.send(UpdateRequest.new("<commit/>"))
assert_equal "<result status=\"0\"></result>", response.raw_response
end
def test_escaping
doc = {:id => 47, :ruby_t => 'puts "ouch!"'}
request = AddDocumentRequest.new(doc)
@connection.send(request)
@connection.send(UpdateRequest.new("<commit/>"))
request = StandardRequest.new
request.query = "ruby_t:ouch"
request.field_list="*,score"
result = @connection.send(request)
assert result.raw_response =~ /puts/
end
end