aboutsummaryrefslogtreecommitdiffstats
path: root/actionwebservice/test
diff options
context:
space:
mode:
authorLeon Breedt <bitserf@gmail.com>2005-03-29 12:31:39 +0000
committerLeon Breedt <bitserf@gmail.com>2005-03-29 12:31:39 +0000
commitb94bd32f3116b469b48400382dbc964bf17994d1 (patch)
tree91752d7e0f49916e5ed2b9e015815c6dc06b4366 /actionwebservice/test
parent715715aed443a027fccbac995cd5404eaeabaf53 (diff)
downloadrails-b94bd32f3116b469b48400382dbc964bf17994d1.tar.gz
rails-b94bd32f3116b469b48400382dbc964bf17994d1.tar.bz2
rails-b94bd32f3116b469b48400382dbc964bf17994d1.zip
first pass of web service scaffolding. add ability to quickly generate an
action pack request for a protocol, add missing log_error when we fail to parse protocol messages. add RDoc for scaffolding and functional testing. git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1037 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionwebservice/test')
-rw-r--r--actionwebservice/test/abstract_dispatcher.rb10
-rw-r--r--actionwebservice/test/api_test.rb4
-rw-r--r--actionwebservice/test/dispatcher_action_controller_soap_test.rb11
-rw-r--r--actionwebservice/test/dispatcher_action_controller_xmlrpc_test.rb10
4 files changed, 13 insertions, 22 deletions
diff --git a/actionwebservice/test/abstract_dispatcher.rb b/actionwebservice/test/abstract_dispatcher.rb
index 21b9a0f5a9..53be05f9f2 100644
--- a/actionwebservice/test/abstract_dispatcher.rb
+++ b/actionwebservice/test/abstract_dispatcher.rb
@@ -301,7 +301,8 @@ module DispatcherCommonTests
[@direct_controller, @delegated_controller].each do |controller|
controller.class.web_service_exception_reporting = true
send_garbage_request = lambda do
- request = create_ap_request(controller, 'invalid request body', 'xxx')
+ service_name = service_name(controller)
+ request = @protocol.create_action_pack_request(service_name, 'broken, method, name!', 'broken request body', :request_class => ActionController::TestRequest)
response = ActionController::TestResponse.new
controller.process(request, response)
# puts response.body
@@ -378,22 +379,25 @@ module DispatcherCommonTests
mode = container.web_service_dispatching_mode
case mode
when :direct
+ service_name = service_name(container)
api = container.class.web_service_api
when :delegated
- api = container.web_service_object(service_name(container)).class.web_service_api
+ service_name = service_name(container)
+ api = container.web_service_object(service_name).class.web_service_api
when :layered
service_name = nil
if public_method_name =~ /^([^\.]+)\.(.*)$/
service_name = $1
end
api = container.web_service_object(service_name.to_sym).class.web_service_api
+ service_name = self.service_name(container)
end
method = api.public_api_method_instance(public_method_name)
method ||= api.dummy_public_api_method_instance(public_method_name)
# we turn off strict so we can test our own handling of incorrectly typed parameters
body = method.encode_rpc_call(@marshaler, @encoder, params.dup, :strict => false)
# puts body
- ap_request = create_ap_request(container, body, public_method_name, *params)
+ ap_request = protocol.create_action_pack_request(service_name, public_method_name, body, :request_class => ActionController::TestRequest)
ap_response = ActionController::TestResponse.new
container.process(ap_request, ap_response)
# puts ap_response.body
diff --git a/actionwebservice/test/api_test.rb b/actionwebservice/test/api_test.rb
index 42b1dfbef2..4a61ae8de7 100644
--- a/actionwebservice/test/api_test.rb
+++ b/actionwebservice/test/api_test.rb
@@ -73,4 +73,8 @@ class TC_API < Test::Unit::TestCase
end
end
end
+
+ def test_to_s
+ assert_equal 'void Expects(int p1, bool p2)', APITest::API.api_methods[:expects].to_s
+ end
end
diff --git a/actionwebservice/test/dispatcher_action_controller_soap_test.rb b/actionwebservice/test/dispatcher_action_controller_soap_test.rb
index 400ab40dd6..76fc6094c2 100644
--- a/actionwebservice/test/dispatcher_action_controller_soap_test.rb
+++ b/actionwebservice/test/dispatcher_action_controller_soap_test.rb
@@ -28,6 +28,7 @@ class TC_DispatcherActionControllerSoap < Test::Unit::TestCase
@direct_controller = DirectController.new
@delegated_controller = DelegatedController.new
@virtual_controller = VirtualController.new
+ @protocol = ActionWebService::Protocol::Soap::SoapProtocol.new
end
def test_wsdl_generation
@@ -70,16 +71,6 @@ class TC_DispatcherActionControllerSoap < Test::Unit::TestCase
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_CONTENT_TYPE'] = '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
diff --git a/actionwebservice/test/dispatcher_action_controller_xmlrpc_test.rb b/actionwebservice/test/dispatcher_action_controller_xmlrpc_test.rb
index 81ada70c9e..c92f270a1b 100644
--- a/actionwebservice/test/dispatcher_action_controller_xmlrpc_test.rb
+++ b/actionwebservice/test/dispatcher_action_controller_xmlrpc_test.rb
@@ -5,6 +5,7 @@ class TC_DispatcherActionControllerXmlRpc < Test::Unit::TestCase
include DispatcherCommonTests
def setup
+ @protocol = ActionWebService::Protocol::XmlRpc::XmlRpcProtocol.new
@encoder = WS::Encoding::XmlRpcEncoding.new
@marshaler = WS::Marshaling::XmlRpcMarshaler.new
@direct_controller = DirectController.new
@@ -29,15 +30,6 @@ class TC_DispatcherActionControllerXmlRpc < Test::Unit::TestCase
obj.is_a?(XMLRPC::FaultException)
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_CONTENT_TYPE'] = 'text/xml'
- test_request.env['RAW_POST_DATA'] = body
- test_request
- end
-
def service_name(container)
container.is_a?(DelegatedController) ? 'test_service' : 'api'
end