Sha256: 804876f67718a7437e33fb6d498dd61bb9d7f0a887f36e5269312a99f1ae6bb2

Contents?: true

Size: 1.53 KB

Versions: 1

Compression:

Stored size: 1.53 KB

Contents

require 'helper'

class TestClientHeaders < Test::Unit::TestCase
  def test_get_headers
    get = HTTP::Get.new("/echo_header")
    get.add_headers(:test_header => "get testing")

    response = @client.execute(get)
    assert_equal("get testing", response)
  end

  def test_post_headers
    get = HTTP::Post.new("/echo_header")
    get.add_headers(:test_header => "post testing")

    response = @client.execute(get)
    assert_equal("post testing", response)
  end

  def test_delete_headers
    get = HTTP::Delete.new("/echo_header")
    get.add_headers(:test_header => "post testing")

    response = @client.execute(get)
    assert_equal("post testing", response)
  end

  def test_put_headers
    get = HTTP::Put.new("/echo_header")
    get.add_headers(:test_header => "post testing")

    response = @client.execute(get)
    assert_equal("post testing", response)
  end

  def test_multiple_calls_to_add_headers_should_prefer_last_set_of_headers
    get = HTTP::Get.new("/echo_header")
    get.add_headers(:test_header => "get testing")
    get.add_headers(:test_header => "should prefer this one")

    response = @client.execute(get)
    assert_equal("should prefer this one", response)
  end

  def test_should_be_able_to_add_content_type
    get = HTTP::Get.new("/echo_header", :header => 'content-type')
    get.content_type = 'text/xml'

    response = @client.execute(get)
    assert_equal('text/xml', response)
  end

  def setup
    @client = HTTP::Client.new(:default_host => "http://localhost:8080")
  end

  def teardown
    @client.shutdown
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
jruby-httpclient-0.3.0-java test/http_client/test_client_headers.rb