2005-02-25 18:39:39 -05:00
|
|
|
require File.dirname(__FILE__) + '/abstract_dispatcher'
|
|
|
|
|
|
|
|
class TC_DispatcherActionControllerXmlRpc < Test::Unit::TestCase
|
|
|
|
include DispatcherTest
|
|
|
|
include DispatcherCommonTests
|
|
|
|
|
|
|
|
def setup
|
|
|
|
@direct_controller = DirectController.new
|
|
|
|
@delegated_controller = DelegatedController.new
|
2005-02-27 16:21:40 -05:00
|
|
|
@layered_controller = LayeredController.new
|
|
|
|
@virtual_controller = VirtualController.new
|
2005-06-25 02:27:39 -04:00
|
|
|
@protocol = ActionWebService::Protocol::XmlRpc::XmlRpcProtocol.create(@direct_controller)
|
2005-02-27 16:21:40 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_layered_dispatching
|
|
|
|
mt_cats = do_method_call(@layered_controller, 'mt.getCategories')
|
|
|
|
assert_equal(["mtCat1", "mtCat2"], mt_cats)
|
|
|
|
blogger_cats = do_method_call(@layered_controller, 'blogger.getCategories')
|
|
|
|
assert_equal(["bloggerCat1", "bloggerCat2"], blogger_cats)
|
2005-02-25 18:39:39 -05:00
|
|
|
end
|
|
|
|
|
2005-08-16 01:45:03 -04:00
|
|
|
def test_multicall
|
|
|
|
response = do_method_call(@layered_controller, 'system.multicall', [
|
|
|
|
{'methodName' => 'mt.getCategories'},
|
|
|
|
{'methodName' => 'blogger.getCategories'},
|
|
|
|
{'methodName' => 'mt.bool'},
|
|
|
|
{'methodName' => 'blogger.str', 'params' => ['2000']},
|
|
|
|
{'methodName' => 'mt.alwaysFail'},
|
2005-08-16 01:54:12 -04:00
|
|
|
{'methodName' => 'blogger.alwaysFail'},
|
|
|
|
{'methodName' => 'mt.blah'},
|
|
|
|
{'methodName' => 'blah.blah'}
|
2005-08-16 01:45:03 -04:00
|
|
|
])
|
|
|
|
assert_equal [
|
|
|
|
[["mtCat1", "mtCat2"]],
|
|
|
|
[["bloggerCat1", "bloggerCat2"]],
|
|
|
|
[true],
|
|
|
|
["2500"],
|
|
|
|
{"faultCode" => 3, "faultString" => "MT AlwaysFail"},
|
2005-08-16 01:54:12 -04:00
|
|
|
{"faultCode" => 3, "faultString" => "Blogger AlwaysFail"},
|
|
|
|
{"faultCode" => 4, "faultMessage" => "no such method 'blah' on API DispatcherTest::MTAPI"},
|
|
|
|
{"faultCode" => 4, "faultMessage" => "no such web service 'blah'"}
|
2005-08-16 01:45:03 -04:00
|
|
|
], response
|
|
|
|
end
|
|
|
|
|
2005-02-25 18:39:39 -05:00
|
|
|
protected
|
|
|
|
def exception_message(xmlrpc_fault_exception)
|
|
|
|
xmlrpc_fault_exception.faultString
|
|
|
|
end
|
|
|
|
|
|
|
|
def is_exception?(obj)
|
|
|
|
obj.is_a?(XMLRPC::FaultException)
|
|
|
|
end
|
|
|
|
|
|
|
|
def service_name(container)
|
|
|
|
container.is_a?(DelegatedController) ? 'test_service' : 'api'
|
|
|
|
end
|
|
|
|
end
|