diff options
Diffstat (limited to 'actionwebservice/test/container_test.rb')
-rw-r--r-- | actionwebservice/test/container_test.rb | 36 |
1 files changed, 28 insertions, 8 deletions
diff --git a/actionwebservice/test/container_test.rb b/actionwebservice/test/container_test.rb index 8c66651b64..325d420f24 100644 --- a/actionwebservice/test/container_test.rb +++ b/actionwebservice/test/container_test.rb @@ -1,7 +1,6 @@ require File.dirname(__FILE__) + '/abstract_unit' module ContainerTest - $immediate_service = Object.new $deferred_service = Object.new @@ -22,22 +21,34 @@ module ContainerTest class DirectContainer < ActionController::Base web_service_dispatching_mode :direct - end + end + + class InvalidContainer + include ActionWebService::Container::Direct + end end class TC_Container < Test::Unit::TestCase + include ContainerTest + def setup - @delegate_container = ContainerTest::DelegateContainer.new - @direct_container = ContainerTest::DirectContainer.new + @delegate_container = DelegateContainer.new + @direct_container = DirectContainer.new end def test_registration - assert(ContainerTest::DelegateContainer.has_web_service?(:immediate_service)) - assert(ContainerTest::DelegateContainer.has_web_service?(:deferred_service)) - assert(!ContainerTest::DelegateContainer.has_web_service?(:fake_service)) + 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?) @@ -48,6 +59,15 @@ class TC_Container < Test::Unit::TestCase end def test_direct_container - assert(ContainerTest::DirectContainer.web_service_dispatching_mode == :direct) + 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 |