mirror of https://github.com/apache/lucene.git
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:
parent
c10a85f982
commit
e6467d8838
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue