removing log dir from .gitignore
[monkeycharger.git] / vendor / rails / actionwebservice / test / dispatcher_action_controller_xmlrpc_test.rb
blob8add57662082bebe049e613240b71198cbf9e5e1
1 require File.dirname(__FILE__) + '/abstract_dispatcher'
3 class TC_DispatcherActionControllerXmlRpc < Test::Unit::TestCase
4   include DispatcherTest
5   include DispatcherCommonTests
7   def setup
8     @direct_controller = DirectController.new
9     @delegated_controller = DelegatedController.new
10     @layered_controller = LayeredController.new
11     @virtual_controller = VirtualController.new
12     @protocol = ActionWebService::Protocol::XmlRpc::XmlRpcProtocol.create(@direct_controller)
13   end
15   def test_layered_dispatching
16     mt_cats = do_method_call(@layered_controller, 'mt.getCategories')
17     assert_equal(["mtCat1", "mtCat2"], mt_cats)
18     blogger_cats = do_method_call(@layered_controller, 'blogger.getCategories')
19     assert_equal(["bloggerCat1", "bloggerCat2"], blogger_cats)
20   end
22   def test_multicall
23     response = do_method_call(@layered_controller, 'system.multicall', [
24       {'methodName' => 'mt.getCategories'},
25       {'methodName' => 'blogger.getCategories'},
26       {'methodName' => 'mt.bool'},
27       {'methodName' => 'blogger.str', 'params' => ['2000']},
28       {'methodName' => 'mt.alwaysFail'},
29       {'methodName' => 'blogger.alwaysFail'},
30       {'methodName' => 'mt.blah'},
31       {'methodName' => 'blah.blah'},
32       {'methodName' => 'mt.person'}
33     ])
34     assert_equal [
35       [["mtCat1", "mtCat2"]],
36       [["bloggerCat1", "bloggerCat2"]],
37       [true],
38       ["2500"],
39       {"faultCode" => 3, "faultString" => "MT AlwaysFail"},
40       {"faultCode" => 3, "faultString" => "Blogger AlwaysFail"},
41       {"faultCode" => 4, "faultMessage" => "no such method 'blah' on API DispatcherTest::MTAPI"},
42       {"faultCode" => 4, "faultMessage" => "no such web service 'blah'"},
43       [{"name"=>"person1", "id"=>1}]
44     ], response
45   end
47   protected
48     def exception_message(xmlrpc_fault_exception)
49       xmlrpc_fault_exception.faultString
50     end
52     def is_exception?(obj)
53       obj.is_a?(XMLRPC::FaultException)
54     end
56     def service_name(container)
57       container.is_a?(DelegatedController) ? 'test_service' : 'api'
58     end
59 end