lucene-solr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Erik Hatcher (JIRA)" <j...@apache.org>
Subject [jira] Commented: (SOLR-132) i18n solrb test patch
Date Thu, 01 Feb 2007 13:48:05 GMT

    [ https://issues.apache.org/jira/browse/SOLR-132?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12469428
] 

Erik Hatcher commented on SOLR-132:
-----------------------------------

Thanks for that patch!   Since this is your first patch, I'll comment on it:

> Index: client/ruby/solrb/test/unit/delete_test.rb

First, you can make the diffs from the solrb directory instead of the root of solr itself.


--- client/ruby/solrb/test/unit/delete_test.rb	(revision 502165)
+++ client/ruby/solrb/test/unit/delete_test.rb	(working copy)
@@ -48,4 +48,9 @@
     assert_equal false, response.ok? 
   end
 
+  def test_delete_by_i18n_query_request
+    request = Solr::Request::Delete.new(:query => 'ëäïöü')
+    assert_equal "<delete><query>ëäïöü</query></delete>", request.to_s
+  end
+

The above is a good test, ensures the XML gets generated as expected.

+  def test_i18n_xml
+    field = Solr::Field.new :i18nstring => 'Äêâîôû Öëäïöü'
+    assert_kind_of REXML::Element, field.to_xml
+    assert_equal "<field name='i18nstring'>Äêâîôû Öëäïöü</field>",
field.to_xml.to_s
+  end
+  

The above is also another good one.

+  def test_add_i18n_document_response
+    conn = Solr::Connection.new('http://localhost:9999/solr')
+    set_post_return('<result status="0"></result>')
+    doc = {:id => '123', :text => '&amp; Clyde, &lt;nicetag/&gt;, ëäïöü
êâîôûå'}
+    response = conn.send(Solr::Request::AddDocument.new(doc))
+    assert_equal true, response.ok?
+  end

This doesn't test anything really, since a mock connection is being used.  This is really
only testing that the <result> is being parsed successfully, but nothing to do with
the add document request.

+  def test_bad_i18n_add_document_response
+    conn = Solr::Connection.new('http://localhost:9999/solr')
+    set_post_return('<result status="400"></result>')
+    doc = {:id => '123', :text => '&amp; Clyde, &lt;nicetag/&gt;, ëäïöü
êâîôûå'}
+    response = conn.send(Solr::Request::AddDocument.new(doc))
+    assert_equal false, response.ok?
+  end

Again, the above is only testing <result> status parsing.

+  def test_i18n_shorthand
+    conn = Solr::Connection.new('http://localhost:9999/solr')
+    set_post_return('<result status="0"></result>')
+    doc = {:id => '123', :text => '&amp; Clyde, &lt;nicetag/&gt;, ëäïöü
êâîôûå'}
+    assert_equal true, conn.add(:id => '123', :text => '&amp; Clyde, &lt;nicetag/&gt;,
ëäïöü êâîôûå')
+  end

And likewise above.

+  def test_add_i18n_doc_request
+    request = Solr::Request::AddDocument.new(:title => "Åëäïöü")
+    assert_equal "<add><doc><field name='title'>Åëäïöü</field></doc></add>",
request.to_s
+    assert_equal :xml, request.response_format
+    assert_equal 'update', request.handler
+    
+    assert_raise(RuntimeError) do
+      Solr::Request::AddDocument.new("invalid")
+    end
+  end
+  
+  def test_add_i18n_multidoc_request
+    request = Solr::Request::AddDocument.new([{:title => "Åëäïöüå"}, {:title =>
"Äëäïöüöå"}])
+    assert_equal "<add><doc><field name='title'>Åëäïöüå</field></doc><doc><field
name='title'>Äëäïöüöå</field></doc></add>", request.to_s
+    assert_equal :xml, request.response_format
+    assert_equal 'update', request.handler
+  end

The above three tests also don't erally test any functionality that wasn't already being tested.

 
--- client/ruby/solrb/test/functional/server_test.rb	(revision 502165)
+++ client/ruby/solrb/test/functional/server_test.rb	(working copy)
@@ -23,7 +23,7 @@
   include Solr
 
   def setup
-    @connection = Connection.new("http://localhost:8888/solr", :autocommit => :on)
+    @connection = Connection.new("http://localhost:8983/solr", :autocommit => :ok)
     clean
   end

Oops... you shouldn't change the Solr port.  Maybe you're running the functional tests outside
of Rake?   If you run "rake test" it'll fire up Solr on port 8888 and run the functional tests
against it.   We should, however, extract the URL out to configurable setting though.

+  def test_i18n_full_lifecycle
+    # make sure autocommit is on
+    assert @connection.autocommit
+
+    # make sure this doc isn't there to begin with
+    @connection.delete(123456)
+
+    # add it
+    @connection.add(:id => 123456, :text => 'Åäöêâîôû')
+
+    # look for it
+    response = @connection.query('Åäöêâîôû')
+    assert_equal 1, response.total_hits
+    assert_equal '123456', response.hits[0]['id']
+
+    # delete it
+    @connection.delete(123456)
+
+    # make sure it's gone
+    response = @connection.query('Åäöêâîôû Öëäïöü')
+    assert_equal 0, response.total_hits
+  end
+  

The above is a NICE test and shows the roundtripping of accented characters into Solr and
back through the solrb API.  Good one.

   def test_bad_url
-    conn = Solr::Connection.new 'http://localhost:8888/invalid'
+    conn = Solr::Connection.new 'http://localhost:8983/invalid'
     assert_raise(Net::HTTPServerException) do
       conn.send(Solr::Request::Ping.new)
     end

Again, don't change this port, but rather run "rake test" instead of using another instance
of Solr.

Thanks for this effort.  I'll commit your tests after you make these adjustments, and we'll
be on our way to a solid i18n solrb.


> i18n solrb test patch
> ---------------------
>
>                 Key: SOLR-132
>                 URL: https://issues.apache.org/jira/browse/SOLR-132
>             Project: Solr
>          Issue Type: Test
>          Components: clients - ruby - flare
>            Reporter: Antonio Eggberg
>            Priority: Trivial
>         Attachments: i18n_test.patch
>
>
> Some unit test in regards to i18n. I didn't create a separate i18n.rb cos it is nothing
but testing new "characters". Please let me know if you would like to have it as a separate
file.. I also added some functional test i.e. i18n_full_cycle_test. 
> This is my first patch :-) I am sure I have made mistake so please do come back with
things that you would like me to change!
> Regards
>  

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message