Return-Path: Delivered-To: apmail-lucene-solr-commits-archive@locus.apache.org Received: (qmail 81624 invoked from network); 4 Jan 2007 18:04:38 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 4 Jan 2007 18:04:38 -0000 Received: (qmail 83957 invoked by uid 500); 4 Jan 2007 17:57:49 -0000 Delivered-To: apmail-lucene-solr-commits-archive@lucene.apache.org Received: (qmail 83736 invoked by uid 500); 4 Jan 2007 17:57:48 -0000 Mailing-List: contact solr-commits-help@lucene.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: solr-dev@lucene.apache.org Delivered-To: mailing list solr-commits@lucene.apache.org Received: (qmail 83238 invoked by uid 99); 4 Jan 2007 17:57:45 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 04 Jan 2007 09:57:45 -0800 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 04 Jan 2007 08:41:05 -0800 Received: by eris.apache.org (Postfix, from userid 65534) id D955A1A981A; Thu, 4 Jan 2007 08:40:08 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: solr-commits@lucene.apache.org From: ehatcher@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20070104164008.D955A1A981A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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("") 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 +