aboutsummaryrefslogtreecommitdiffstats
path: root/actionwebservice/test/dispatcher_action_controller_soap_test.rb
diff options
context:
space:
mode:
authorLeon Breedt <bitserf@gmail.com>2005-02-25 23:39:39 +0000
committerLeon Breedt <bitserf@gmail.com>2005-02-25 23:39:39 +0000
commit6f5a7b200443baf209d2f33c428ed4a4059782f7 (patch)
tree9c3942fe27be69c102873d9fdaa13f66dc12853d /actionwebservice/test/dispatcher_action_controller_soap_test.rb
parent10faf204b712763f05a2b3155a4fd9c5338f1fb2 (diff)
downloadrails-6f5a7b200443baf209d2f33c428ed4a4059782f7.tar.gz
rails-6f5a7b200443baf209d2f33c428ed4a4059782f7.tar.bz2
rails-6f5a7b200443baf209d2f33c428ed4a4059782f7.zip
merged the changes for the upcoming 0.6.0:
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
Diffstat (limited to 'actionwebservice/test/dispatcher_action_controller_soap_test.rb')
-rw-r--r--actionwebservice/test/dispatcher_action_controller_soap_test.rb93
1 files changed, 93 insertions, 0 deletions
diff --git a/actionwebservice/test/dispatcher_action_controller_soap_test.rb b/actionwebservice/test/dispatcher_action_controller_soap_test.rb
new file mode 100644
index 0000000000..9cb99be78d
--- /dev/null
+++ b/actionwebservice/test/dispatcher_action_controller_soap_test.rb
@@ -0,0 +1,93 @@
+$:.unshift(File.dirname(__FILE__) + '/apis')
+require File.dirname(__FILE__) + '/abstract_dispatcher'
+require 'wsdl/parser'
+
+class AutoLoadController < ActionController::Base; end
+class FailingAutoLoadController < ActionController::Base; end
+class BrokenAutoLoadController < ActionController::Base; end
+
+class TC_DispatcherActionControllerSoap < Test::Unit::TestCase
+ include DispatcherTest
+ include DispatcherCommonTests
+
+ def setup
+ @encoder = WS::Encoding::SoapRpcEncoding.new
+ @marshaler = WS::Marshaling::SoapMarshaler.new
+ @direct_controller = DirectController.new
+ @delegated_controller = DelegatedController.new
+ end
+
+ def test_wsdl_generation
+ ensure_valid_wsdl_generation DelegatedController.new
+ ensure_valid_wsdl_generation DirectController.new
+ end
+
+ def test_wsdl_action
+ ensure_valid_wsdl_action DelegatedController.new
+ ensure_valid_wsdl_action DirectController.new
+ end
+
+ def test_autoloading
+ assert(!AutoLoadController.web_service_api.nil?)
+ assert(AutoLoadController.web_service_api.has_public_api_method?('Void'))
+ assert(FailingAutoLoadController.web_service_api.nil?)
+ assert_raises(LoadError, NameError) do
+ FailingAutoLoadController.require_web_service_api :blah
+ end
+ assert_raises(ArgumentError) do
+ FailingAutoLoadController.require_web_service_api 50.0
+ end
+ assert(BrokenAutoLoadController.web_service_api.nil?)
+ end
+
+ protected
+ def exception_message(soap_fault_exception)
+ soap_fault_exception.detail.cause.message
+ end
+
+ def is_exception?(obj)
+ obj.respond_to?(:detail) && obj.detail.respond_to?(:cause) && \
+ obj.detail.cause.is_a?(Exception)
+ end
+
+ def create_ap_request(container, body, public_method_name, *args)
+ test_request = ActionController::TestRequest.new
+ test_request.request_parameters['action'] = service_name(container)
+ test_request.env['REQUEST_METHOD'] = "POST"
+ test_request.env['HTTP_CONTENTTYPE'] = 'text/xml'
+ test_request.env['HTTP_SOAPACTION'] = "/soap/#{service_name(container)}/#{public_method_name}"
+ test_request.env['RAW_POST_DATA'] = body
+ test_request
+ end
+
+ def service_name(container)
+ container.is_a?(DelegatedController) ? 'test_service' : 'api'
+ end
+
+ def ensure_valid_wsdl_generation(controller)
+ wsdl = controller.generate_wsdl
+ ensure_valid_wsdl(wsdl)
+ end
+
+ def ensure_valid_wsdl(wsdl)
+ definitions = WSDL::Parser.new.parse(wsdl)
+ assert(definitions.is_a?(WSDL::Definitions))
+ definitions.bindings.each do |binding|
+ assert(binding.name.name.index(':').nil?)
+ end
+ definitions.services.each do |service|
+ service.ports.each do |port|
+ assert(port.name.name.index(':').nil?)
+ end
+ end
+ end
+
+ def ensure_valid_wsdl_action(controller)
+ test_request = ActionController::TestRequest.new({ 'action' => 'wsdl' })
+ test_request.env['REQUEST_METHOD'] = 'GET'
+ test_request.env['HTTP_HOST'] = 'localhost:3000'
+ test_response = ActionController::TestResponse.new
+ wsdl = controller.process(test_request, test_response).body
+ ensure_valid_wsdl(wsdl)
+ end
+end