lucene-solr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ehatc...@apache.org
Subject svn commit: r492628 - in /incubator/solr/trunk/client/ruby/solrb: lib/solr/connection.rb test/connection_test.rb test/test_helper.rb
Date Thu, 04 Jan 2007 16:40:08 GMT
Author: ehatcher
Date: Thu Jan  4 08:40:07 2007
New Revision: 492628

URL: http://svn.apache.org/viewvc?view=rev&rev=492628
Log:
first attempt at making a mock Solr::Connection base test case

Modified:
    incubator/solr/trunk/client/ruby/solrb/lib/solr/connection.rb
    incubator/solr/trunk/client/ruby/solrb/test/connection_test.rb
    incubator/solr/trunk/client/ruby/solrb/test/test_helper.rb

Modified: incubator/solr/trunk/client/ruby/solrb/lib/solr/connection.rb
URL: http://svn.apache.org/viewvc/incubator/solr/trunk/client/ruby/solrb/lib/solr/connection.rb?view=diff&rev=492628&r1=492627&r2=492628
==============================================================================
--- incubator/solr/trunk/client/ruby/solrb/lib/solr/connection.rb (original)
+++ incubator/solr/trunk/client/ruby/solrb/lib/solr/connection.rb Thu Jan  4 08:40:07 2007
@@ -21,13 +21,19 @@
     end
 
     def send(request)
+      data = post(request)
+      return request.response_format == :ruby ? RubyResponse.new(data) : XmlResponse.new(data)
+    end
+    
+    def post(request)
       post = Net::HTTP::Post.new(request.url_path)
       post.body = request.to_http_body
       post.content_type = 'application/x-www-form-urlencoded; charset=utf-8'
       response = Net::HTTP.start(@url.host, @url.port) do |http|
         http.request(post)
       end
-      return request.response_format == :ruby ? RubyResponse.new(response.body) : XmlResponse.new(response.body)
+      
+      return response.body
     end
   end
 end

Modified: incubator/solr/trunk/client/ruby/solrb/test/connection_test.rb
URL: http://svn.apache.org/viewvc/incubator/solr/trunk/client/ruby/solrb/test/connection_test.rb?view=diff&rev=492628&r1=492627&r2=492628
==============================================================================
--- incubator/solr/trunk/client/ruby/solrb/test/connection_test.rb (original)
+++ incubator/solr/trunk/client/ruby/solrb/test/connection_test.rb Thu Jan  4 08:40:07 2007
@@ -13,7 +13,22 @@
 require 'test/unit'
 require 'solr'
 
-class ConnectionTest < Test::Unit::TestCase
+module Solr
+  class Connection
+    def post(request)
+      "foo"
+    end
+  end
+  
+  class MockSolrBaseTest < Test::Unit::TestCase
+    def test_mock
+      connection = Connection.new("http://localhost:9999")
+      assert_equal "foo", connection.post(UpdateRequest.new("bogus"))
+    end
+  end
+end
+
+class ConnectionTest < Solr::MockSolrBaseTest
   def test_connection_initialize
     request = Solr::UpdateRequest.new("<commit/>")
     connection = Solr::Connection.new("http://localhost:8983")

Modified: incubator/solr/trunk/client/ruby/solrb/test/test_helper.rb
URL: http://svn.apache.org/viewvc/incubator/solr/trunk/client/ruby/solrb/test/test_helper.rb?view=diff&rev=492628&r1=492627&r2=492628
==============================================================================
--- incubator/solr/trunk/client/ruby/solrb/test/test_helper.rb (original)
+++ incubator/solr/trunk/client/ruby/solrb/test/test_helper.rb Thu Jan  4 08:40:07 2007
@@ -10,6 +10,8 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+require 'test/unit'
+
 def start_solr_server
   Dir.chdir(File.dirname(__FILE__) + '/../solr') do 
     puts "starting solr server"
@@ -32,3 +34,4 @@
   puts "stopping solr server"
   Process.kill('TERM', $SOLR_PID)
 end
+



Mime
View raw message