Sha256: cfe1c255a0e518c582763a78365a9ec21562b56e5bf1f7c5a65fd1c6d677c86b

Contents?: true

Size: 1.86 KB

Versions: 9

Compression:

Stored size: 1.86 KB

Contents

# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License.  You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

require 'test/unit'
require 'solr'
require 'solr_mock_base'

class ConnectionTest < SolrMockBaseTestCase
  def test_mock
    connection = Connection.new("http://localhost:9999")
    set_post_return("foo")
    assert_equal "foo", connection.post(Solr::Request::AddDocument.new)
  end
  
  def test_bad_url
    assert_raise(RuntimeError) do
      Connection.new("ftp://localhost:9999")
    end
  end

  def test_connection_initialize
    connection = Solr::Connection.new("http://localhost:8983/solr")
    assert_equal 'localhost', connection.url.host
    assert_equal 8983, connection.url.port
    assert_equal '/solr', connection.url.path
  end

  def test_non_standard_context
    connection = Solr::Connection.new("http://localhost:8983/index")
    assert_equal '/index', connection.url.path
  end

  def test_xml_response
    connection = Connection.new("http://localhost:9999")
    set_post_return "<bogus/>"
    response = connection.send(Solr::Request::Ping.new)
    assert_equal "<bogus/>", response.raw_response
  end

  def test_ruby_response
    connection = Connection.new("http://localhost:9999")
    set_post_return "{'responseHeader' => {}, 'response' => {}}"
    response = connection.send(Solr::Request::Standard.new(:query => 'foo'))
    assert_equal({'responseHeader' => {}, 'response' => {}}, response.data)
  end
end

Version data entries

9 entries across 9 versions & 2 rubygems

Version Path
greglu-solr-ruby-0.0.7 test/unit/connection_test.rb
solr-ruby-0.0.8 test/unit/connection_test.rb
solr-ruby-0.0.7 test/unit/connection_test.rb
solr-ruby-0.0.1 test/unit/connection_test.rb
solr-ruby-0.0.3 test/unit/connection_test.rb
solr-ruby-0.0.2 test/unit/connection_test.rb
solr-ruby-0.0.4 test/unit/connection_test.rb
solr-ruby-0.0.6 test/unit/connection_test.rb
solr-ruby-0.0.5 test/unit/connection_test.rb