Sha256: a9e516632cde3613a0c40b727cdf84f9edc83508c43a2c68d1494416cc1b34c4

Contents?: true

Size: 910 Bytes

Versions: 3

Compression:

Stored size: 910 Bytes

Contents

require File.dirname(__FILE__) + '/helper'
require 'xmlrpc/client'

class XmlrpcSessionClientTest < OpenX::TestCase

  def client
    @client ||= OpenX::XmlrpcSessionClient.new(stub_session)
  end

  def stub_session
    stub(:url => "http://example.com/random/path", :id => 33)
  end

  def stub_xrc
    stub(:call => nil, :timeout= => 10)
  end

  test "call forwarding" do
    client.client.expects(:call).with('ox.getAgency', 33, 1)
    client.call('ox.getAgency', 1)
  end

  test "call rescueing" do
    a, b = stub_xrc, stub_xrc
    ::XMLRPC::Client.stubs(:new2).returns(a, b)

    a.expects(:call).once.raises(Net::HTTPBadResponse, 'Bad response')
    b.expects(:call).once.raises(XMLRPC::FaultException.new(0, 'session id is invalid'))
    client.session.expects(:recreate!).once

    client.call('ox.getAgency', 1)
    assert_not_equal  client.client, a
    assert_equal  client.client, b
  end

end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
krakatoa-openx-1.9.4 test/test_xmlrpc_session_client.rb
bsm-openx-1.9.4 test/test_xmlrpc_session_client.rb
bsm-openx-1.9.3 test/test_xmlrpc_session_client.rb