mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
6f5a7b2004
seperate out protocol marshaling into a small 'ws' library in vendor, so that AWS itself only does integration with ActionPack, and so we can keep protocol specific code in AWS proper to a minimum. refactor unit tests to get 95% code coverage (for a baseline). be far more relaxed about the types given to us by the remote side, don't do any poor man's type checking, just try to cast and marshal to the correct types if possible, and if not, return what they gave us anyway. this should make interoperating with fuzzy XML-RPC clients easier. if exception reporting is turned on, do best-effort error responses, so that we can avoid "Internal protocol error" with no details if there is a bug in AWS itself. also perform extensive cleanups on AWS proper. git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@800 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
73 lines
2.2 KiB
Ruby
73 lines
2.2 KiB
Ruby
require File.dirname(__FILE__) + '/abstract_unit'
|
|
|
|
module ContainerTest
|
|
$immediate_service = Object.new
|
|
$deferred_service = Object.new
|
|
|
|
class DelegateContainer < ActionController::Base
|
|
web_service_dispatching_mode :delegated
|
|
|
|
attr :flag
|
|
attr :previous_flag
|
|
|
|
def initialize
|
|
@previous_flag = nil
|
|
@flag = true
|
|
end
|
|
|
|
web_service :immediate_service, $immediate_service
|
|
web_service(:deferred_service) { @previous_flag = @flag; @flag = false; $deferred_service }
|
|
end
|
|
|
|
class DirectContainer < ActionController::Base
|
|
web_service_dispatching_mode :direct
|
|
end
|
|
|
|
class InvalidContainer
|
|
include ActionWebService::Container::Direct
|
|
end
|
|
end
|
|
|
|
class TC_Container < Test::Unit::TestCase
|
|
include ContainerTest
|
|
|
|
def setup
|
|
@delegate_container = DelegateContainer.new
|
|
@direct_container = DirectContainer.new
|
|
end
|
|
|
|
def test_registration
|
|
assert(DelegateContainer.has_web_service?(:immediate_service))
|
|
assert(DelegateContainer.has_web_service?(:deferred_service))
|
|
assert(!DelegateContainer.has_web_service?(:fake_service))
|
|
assert_raises(ActionWebService::Container::Delegated::ContainerError) do
|
|
DelegateContainer.web_service('invalid')
|
|
end
|
|
end
|
|
|
|
def test_service_object
|
|
assert_raises(ActionWebService::Container::Delegated::ContainerError) do
|
|
@delegate_container.web_service_object(:nonexistent)
|
|
end
|
|
assert(@delegate_container.flag == true)
|
|
assert(@delegate_container.web_service_object(:immediate_service) == $immediate_service)
|
|
assert(@delegate_container.previous_flag.nil?)
|
|
assert(@delegate_container.flag == true)
|
|
assert(@delegate_container.web_service_object(:deferred_service) == $deferred_service)
|
|
assert(@delegate_container.previous_flag == true)
|
|
assert(@delegate_container.flag == false)
|
|
end
|
|
|
|
def test_direct_container
|
|
assert(DirectContainer.web_service_dispatching_mode == :direct)
|
|
end
|
|
|
|
def test_validity
|
|
assert_raises(ActionWebService::Container::Direct::ContainerError) do
|
|
InvalidContainer.web_service_api :test
|
|
end
|
|
assert_raises(ActionWebService::Container::Direct::ContainerError) do
|
|
InvalidContainer.web_service_api 50.0
|
|
end
|
|
end
|
|
end
|