actionservice 0.2.100 → 0.2.102
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +3 -0
- data/README +39 -12
- data/Rakefile +7 -4
- data/TODO +12 -29
- data/examples/soap/app/controllers/search_controller.rb +1 -2
- data/examples/soap/lib/google_search_service.rb +5 -2
- data/lib/action_service/base.rb +2 -57
- data/lib/action_service/container.rb +88 -36
- data/lib/action_service/exporting.rb +140 -0
- data/lib/action_service/invocation.rb +46 -16
- data/lib/action_service/protocol/abstract.rb +80 -50
- data/lib/action_service/protocol/registry.rb +3 -5
- data/lib/action_service/protocol/soap.rb +156 -80
- data/lib/action_service/protocol/xmlrpc.rb +77 -47
- data/lib/action_service/router/action_controller.rb +41 -29
- data/lib/action_service/router/wsdl.rb +149 -132
- data/lib/action_service.rb +5 -0
- data/test/abstract_soap.rb +47 -0
- data/test/base_test.rb +31 -29
- data/test/container_test.rb +53 -32
- data/test/invocation_test.rb +97 -86
- data/test/protocol_registry_test.rb +9 -10
- data/test/protocol_soap_test.rb +125 -159
- data/test/protocol_xmlrpc_test.rb +61 -58
- data/test/router_action_controller_test.rb +52 -83
- data/test/router_wsdl_test.rb +31 -25
- data/test/struct_test.rb +11 -9
- metadata +15 -3
- data/CHANGELOG +0 -3
data/test/protocol_soap_test.rb
CHANGED
@@ -1,181 +1,147 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/
|
2
|
-
|
3
|
-
|
4
|
-
class
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
@default_args = nil
|
1
|
+
require File.dirname(__FILE__) + '/abstract_soap'
|
2
|
+
|
3
|
+
module ProtocolSoapTest
|
4
|
+
class Person < ActionService::Struct
|
5
|
+
member :id, Integer
|
6
|
+
member :names, [String]
|
7
|
+
member :lastname, String
|
8
|
+
member :deleted, TrueClass
|
9
|
+
|
10
|
+
def ==(other)
|
11
|
+
id == other.id && names == other.names && lastname == other.lastname && deleted == other.deleted
|
12
|
+
end
|
14
13
|
end
|
15
14
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
15
|
+
class Service < ActionService::Base
|
16
|
+
attr :int
|
17
|
+
attr :string
|
18
|
+
attr :array
|
19
|
+
attr :values
|
20
|
+
attr :person
|
21
|
+
attr :default_args
|
22
|
+
|
23
|
+
def initialize
|
24
|
+
@int = 20
|
25
|
+
@string = "wrong string value"
|
26
|
+
@default_args = nil
|
27
|
+
end
|
28
|
+
|
29
|
+
def argument_passing(int, string, array)
|
30
|
+
@int = int
|
31
|
+
@string = string
|
32
|
+
@array = array
|
33
|
+
true
|
34
|
+
end
|
35
|
+
|
36
|
+
def array_returner
|
37
|
+
@values = [1, 2, 3]
|
38
|
+
end
|
39
|
+
|
40
|
+
def nil_returner
|
41
|
+
nil
|
42
|
+
end
|
43
|
+
|
44
|
+
def struct_array_returner
|
45
|
+
@person = Person.new
|
46
|
+
@person.id = 5
|
47
|
+
@person.names = ["one", "two"]
|
48
|
+
@person.lastname = "test"
|
49
|
+
@person.deleted = false
|
50
|
+
[@person]
|
51
|
+
end
|
52
|
+
|
53
|
+
def exception_thrower
|
54
|
+
raise "Hi, I'm a SOAP error"
|
55
|
+
end
|
56
|
+
|
57
|
+
def default(*args)
|
58
|
+
@default_args = args
|
59
|
+
nil
|
60
|
+
end
|
61
|
+
|
62
|
+
export :argument_passing, :expects => [Integer, String, [Integer]], :returns => [TrueClass]
|
63
|
+
export :array_returner, :returns => [[Integer]]
|
64
|
+
export :nil_returner
|
65
|
+
export :struct_array_returner, :returns => [[Person]]
|
66
|
+
export :exception_thrower
|
67
|
+
|
68
|
+
default_export :default
|
20
69
|
end
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
70
|
+
|
71
|
+
class Container
|
72
|
+
include ActionService::Container
|
73
|
+
include ActionService::Protocol::Registry
|
74
|
+
include ActionService::Protocol::Soap
|
75
|
+
|
76
|
+
def protocol_request(request)
|
77
|
+
probe_request_protocol(request)
|
78
|
+
end
|
79
|
+
|
80
|
+
def dispatch_request(protocol_request)
|
81
|
+
dispatch_service_request(protocol_request)
|
82
|
+
end
|
83
|
+
|
84
|
+
wsdl_service_name 'Test'
|
85
|
+
service_dispatching_mode :delegated
|
86
|
+
service :protocol_soap_service, Service.new
|
29
87
|
end
|
30
|
-
|
31
|
-
export :some_method, :expects => [Integer, String], :returns => [TrueClass]
|
32
|
-
export :array_returner, :returns => [[Integer]]
|
33
|
-
|
34
|
-
default_export :default
|
35
88
|
end
|
36
89
|
|
37
|
-
class
|
38
|
-
|
39
|
-
|
40
|
-
include ActionService::Protocol::Soap
|
41
|
-
|
42
|
-
def request_protocol(request)
|
43
|
-
probe_request_protocol(request)
|
90
|
+
class TC_ProtocolSoap < AbstractSoapTest
|
91
|
+
def setup
|
92
|
+
@container = ProtocolSoapTest::Container.new
|
44
93
|
end
|
45
94
|
|
46
|
-
def
|
47
|
-
|
95
|
+
def test_argument_passing
|
96
|
+
assert(do_soap_call('ArgumentPassing', 5, "test string", [true, false]) == true)
|
97
|
+
assert(service.int == 5)
|
98
|
+
assert(service.string == "test string")
|
99
|
+
assert(service.array == [true, false])
|
48
100
|
end
|
49
101
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
class ProtocolSoapTest < Test::Unit::TestCase
|
55
|
-
def setup
|
56
|
-
@container = SoapContainer.new
|
102
|
+
def test_array_returner
|
103
|
+
assert(do_soap_call('ArrayReturner') == [1, 2, 3])
|
104
|
+
assert(service.values == [1, 2, 3])
|
57
105
|
end
|
58
106
|
|
59
|
-
def
|
60
|
-
|
61
|
-
public_method_name = 'SomeMethod'
|
62
|
-
int_value = 5
|
63
|
-
string_value = "test string"
|
64
|
-
qname = XSD::QName.new('urn:ActionService', public_method_name)
|
65
|
-
param_def = [
|
66
|
-
['in', 'param1', [SOAP::SOAPInt]],
|
67
|
-
['in', 'param2', [SOAP::SOAPString]],
|
68
|
-
]
|
69
|
-
request = SOAP::RPC::SOAPMethodRequest.new(qname, param_def)
|
70
|
-
request.set_param([
|
71
|
-
['param1', SOAP::Mapping.obj2soap(int_value)],
|
72
|
-
['param2', SOAP::Mapping.obj2soap(string_value)]
|
73
|
-
])
|
74
|
-
header = SOAP::SOAPHeader.new
|
75
|
-
body = SOAP::SOAPBody.new(request)
|
76
|
-
envelope = SOAP::SOAPEnvelope.new(header, body)
|
77
|
-
raw_request = SOAP::Processor.marshal(envelope)
|
78
|
-
test_request = ActionController::TestRequest.new
|
79
|
-
test_request.request_parameters['action'] = service_name
|
80
|
-
test_request.env['REQUEST_METHOD'] = "POST"
|
81
|
-
test_request.env['HTTP_CONTENTTYPE'] = 'text/xml'
|
82
|
-
test_request.env['HTTP_SOAPACTION'] = "/soap/#{service_name}/#{public_method_name}"
|
83
|
-
test_request.env['RAW_POST_DATA'] = raw_request
|
84
|
-
protocol = @container.request_protocol(test_request)
|
85
|
-
assert(protocol.is_a?(ActionService::Protocol::Soap::SoapProtocol))
|
86
|
-
request_info = protocol.request_info
|
87
|
-
assert(request_info.service_name == service_name)
|
88
|
-
assert(request_info.public_method_name == public_method_name)
|
89
|
-
method_name = SoapService.internal_export_name(public_method_name)
|
90
|
-
export_info = SoapService.exports[method_name]
|
91
|
-
params = protocol.unmarshal_request(request_info, export_info)
|
92
|
-
assert(params.length == 2)
|
93
|
-
assert(params == [int_value, string_value])
|
94
|
-
response = @container.dispatch_request(protocol, request_info)
|
95
|
-
service = @container.service_object(:soap_service)
|
96
|
-
assert(service.int == int_value)
|
97
|
-
assert(service.string == string_value)
|
98
|
-
raw_response = response.raw_body
|
99
|
-
envelope = SOAP::Processor.unmarshal(raw_response)
|
100
|
-
assert(envelope.is_a?(SOAP::SOAPEnvelope))
|
101
|
-
resp = envelope.body.response
|
102
|
-
assert(resp.is_a?(SOAP::SOAPBoolean))
|
103
|
-
assert(resp.data == true)
|
107
|
+
def test_nil_returner
|
108
|
+
assert(do_soap_call('NilReturner') == nil)
|
104
109
|
end
|
105
110
|
|
106
|
-
def
|
107
|
-
assert(
|
111
|
+
def test_struct_array_returner
|
112
|
+
assert(do_soap_call('StructArrayReturner') == [service.person])
|
108
113
|
end
|
109
114
|
|
110
|
-
def
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
body = SOAP::SOAPBody.new(request)
|
117
|
-
envelope = SOAP::SOAPEnvelope.new(header, body)
|
118
|
-
raw_request = SOAP::Processor.marshal(envelope)
|
119
|
-
test_request = ActionController::TestRequest.new
|
120
|
-
test_request.request_parameters['action'] = service_name
|
121
|
-
test_request.env['REQUEST_METHOD'] = "POST"
|
122
|
-
test_request.env['HTTP_CONTENTTYPE'] = 'text/xml'
|
123
|
-
test_request.env['HTTP_SOAPACTION'] = "/soap/#{service_name}/#{public_method_name}"
|
124
|
-
test_request.env['RAW_POST_DATA'] = raw_request
|
125
|
-
protocol = @container.request_protocol(test_request)
|
126
|
-
assert(protocol.is_a?(ActionService::Protocol::Soap::SoapProtocol))
|
127
|
-
request_info = protocol.request_info
|
128
|
-
method_name = SoapService.internal_export_name(public_method_name)
|
129
|
-
export_info = SoapService.exports[method_name]
|
130
|
-
response = @container.dispatch_request(protocol, request_info)
|
131
|
-
service = @container.service_object(:soap_service)
|
132
|
-
assert(service.values == [1, 2, 3])
|
133
|
-
raw_response = response.raw_body
|
134
|
-
envelope = SOAP::Processor.unmarshal(raw_response)
|
135
|
-
assert(envelope.is_a?(SOAP::SOAPEnvelope))
|
136
|
-
resp = envelope.body.response
|
137
|
-
assert(resp.is_a?(SOAP::SOAPArray))
|
138
|
-
assert(SOAP::Mapping.soap2obj(resp) == [1, 2, 3])
|
115
|
+
def test_exception_thrower
|
116
|
+
assert_raises(RuntimeError) do
|
117
|
+
do_soap_call('ExceptionThrower')
|
118
|
+
end
|
119
|
+
#assert(obj.detail.is_a?(SOAP::Mapping::SOAPException))
|
120
|
+
#assert(obj.faultstring == "Hi, I'm a SOAP error")
|
139
121
|
end
|
140
122
|
|
141
123
|
def test_default_export
|
142
|
-
|
143
|
-
public_method_name = 'NonExistentMethodName'
|
144
|
-
qname = XSD::QName.new('urn:ActionService', public_method_name)
|
145
|
-
int_value = 50
|
146
|
-
bool_value = false
|
147
|
-
param_def = [
|
148
|
-
['in', 'param1', [SOAP::SOAPInt]],
|
149
|
-
['in', 'param2', [SOAP::SOAPBoolean]],
|
150
|
-
]
|
151
|
-
request = SOAP::RPC::SOAPMethodRequest.new(qname, param_def)
|
152
|
-
request.set_param([
|
153
|
-
['param1', SOAP::Mapping.obj2soap(int_value)],
|
154
|
-
['param2', SOAP::Mapping.obj2soap(bool_value)]
|
155
|
-
])
|
156
|
-
header = SOAP::SOAPHeader.new
|
157
|
-
body = SOAP::SOAPBody.new(request)
|
158
|
-
envelope = SOAP::SOAPEnvelope.new(header, body)
|
159
|
-
raw_request = SOAP::Processor.marshal(envelope)
|
160
|
-
test_request = ActionController::TestRequest.new
|
161
|
-
test_request.request_parameters['action'] = service_name
|
162
|
-
test_request.env['REQUEST_METHOD'] = "POST"
|
163
|
-
test_request.env['HTTP_CONTENTTYPE'] = 'text/xml'
|
164
|
-
test_request.env['HTTP_SOAPACTION'] = "/soap/#{service_name}/#{public_method_name}"
|
165
|
-
test_request.env['RAW_POST_DATA'] = raw_request
|
166
|
-
protocol = @container.request_protocol(test_request)
|
167
|
-
assert(protocol.is_a?(ActionService::Protocol::Soap::SoapProtocol))
|
168
|
-
request_info = protocol.request_info
|
169
|
-
method_name = SoapService.internal_export_name(public_method_name)
|
170
|
-
export_info = SoapService.exports[method_name]
|
171
|
-
service = @container.service_object(:soap_service)
|
172
|
-
assert(service.default_args.nil?)
|
173
|
-
response = @container.dispatch_request(protocol, request_info)
|
174
|
-
raw_response = response.raw_body
|
175
|
-
envelope = SOAP::Processor.unmarshal(raw_response)
|
176
|
-
assert(envelope.is_a?(SOAP::SOAPEnvelope))
|
177
|
-
resp = envelope.body.response
|
178
|
-
assert(resp.is_a?(SOAP::SOAPNil))
|
124
|
+
assert(do_soap_call('NonExistentMethodName', 50, false).nil?)
|
179
125
|
assert(service.default_args == [50, false])
|
180
126
|
end
|
127
|
+
|
128
|
+
def test_service_name_setting
|
129
|
+
assert(ProtocolSoapTest::Container.soap_mapper.custom_namespace == 'urn:Test')
|
130
|
+
end
|
131
|
+
|
132
|
+
protected
|
133
|
+
def service_name
|
134
|
+
'protocol_soap_service'
|
135
|
+
end
|
136
|
+
|
137
|
+
def service
|
138
|
+
@container.service_object(:protocol_soap_service)
|
139
|
+
end
|
140
|
+
|
141
|
+
def do_soap_call(public_method_name, *args)
|
142
|
+
super(public_method_name, *args) do |test_request, test_response|
|
143
|
+
protocol_request = @container.protocol_request(test_request)
|
144
|
+
@container.dispatch_request(protocol_request)
|
145
|
+
end
|
146
|
+
end
|
181
147
|
end
|
@@ -17,69 +17,72 @@ module XMLRPC
|
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
def initialize
|
26
|
-
@result = nil
|
27
|
-
@hashvalue = nil
|
28
|
-
@default_args = nil
|
29
|
-
end
|
30
|
-
|
31
|
-
def add(a, b)
|
32
|
-
@result = a + b
|
33
|
-
end
|
34
|
-
|
35
|
-
def something_hash(hash)
|
36
|
-
@hashvalue = hash
|
37
|
-
end
|
38
|
-
|
39
|
-
def array_returner
|
40
|
-
[1, 2, 3]
|
41
|
-
end
|
20
|
+
module ProtocolXmlRpcTest
|
21
|
+
class Service < ActionService::Base
|
22
|
+
attr :result
|
23
|
+
attr :hashvalue
|
24
|
+
attr :default_args
|
42
25
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
26
|
+
def initialize
|
27
|
+
@result = nil
|
28
|
+
@hashvalue = nil
|
29
|
+
@default_args = nil
|
30
|
+
end
|
31
|
+
|
32
|
+
def add(a, b)
|
33
|
+
@result = a + b
|
34
|
+
end
|
35
|
+
|
36
|
+
def something_hash(hash)
|
37
|
+
@hashvalue = hash
|
38
|
+
end
|
39
|
+
|
40
|
+
def array_returner
|
41
|
+
[1, 2, 3]
|
42
|
+
end
|
43
|
+
|
44
|
+
def hash_returner
|
45
|
+
{'name' => 1, 'value' => 2}
|
46
|
+
end
|
47
|
+
|
48
|
+
def default(*args)
|
49
|
+
@default_args = args
|
50
|
+
nil
|
51
|
+
end
|
52
|
+
|
53
|
+
export :add, :expects => [Integer, Integer], :returns => [Integer]
|
54
|
+
export :hash_returner, :returns => [Hash]
|
55
|
+
export :array_returner, :returns => [[Integer]]
|
56
|
+
export :something_hash, :expects => [Hash]
|
57
|
+
|
58
|
+
default_export :default
|
70
59
|
end
|
71
|
-
|
72
|
-
|
73
|
-
|
60
|
+
|
61
|
+
$service = Service.new
|
62
|
+
|
63
|
+
class Container
|
64
|
+
include ActionService::Container
|
65
|
+
include ActionService::Protocol::Registry
|
66
|
+
include ActionService::Protocol::Soap
|
67
|
+
include ActionService::Protocol::XmlRpc
|
68
|
+
|
69
|
+
def protocol_request(request)
|
70
|
+
probe_request_protocol(request)
|
71
|
+
end
|
72
|
+
|
73
|
+
def dispatch_request(protocol_request)
|
74
|
+
dispatch_service_request(protocol_request)
|
75
|
+
end
|
76
|
+
|
77
|
+
service :xmlrpc, $service
|
78
|
+
service_dispatching_mode :delegated
|
74
79
|
end
|
75
|
-
|
76
|
-
service :xmlrpc, $service
|
77
80
|
end
|
78
81
|
|
79
|
-
class
|
82
|
+
class TC_ProtocolXmlRpc < Test::Unit::TestCase
|
80
83
|
def setup
|
81
84
|
@helper = XMLRPC::XmlRpcHelper.new
|
82
|
-
@container =
|
85
|
+
@container = ProtocolXmlRpcTest::Container.new
|
83
86
|
end
|
84
87
|
|
85
88
|
def test_xmlrpc_request_dispatching
|
@@ -123,8 +126,8 @@ class ProtocolXmlRpcTest < Test::Unit::TestCase
|
|
123
126
|
test_request.env['REQUEST_METHOD'] = "POST"
|
124
127
|
test_request.env['HTTP_CONTENTTYPE'] = 'text/xml'
|
125
128
|
test_request.env['RAW_POST_DATA'] = raw_request
|
126
|
-
|
127
|
-
response = @container.dispatch_request(
|
129
|
+
protocol_request = @container.protocol_request(test_request)
|
130
|
+
response = @container.dispatch_request(protocol_request)
|
128
131
|
@helper.parse_response(response.raw_body)
|
129
132
|
end
|
130
133
|
end
|
@@ -1,98 +1,67 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/
|
1
|
+
require File.dirname(__FILE__) + '/abstract_soap'
|
2
2
|
require 'wsdl/parser'
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
def initialize
|
15
|
-
@added = nil
|
4
|
+
module RouterActionControllerTest
|
5
|
+
class Service < ActionService::Base
|
6
|
+
attr :added
|
7
|
+
|
8
|
+
def add(a, b)
|
9
|
+
@added = a + b
|
10
|
+
end
|
11
|
+
|
12
|
+
export :add, :expects => [Integer, Integer], :returns => [Integer]
|
16
13
|
end
|
17
14
|
|
18
|
-
|
19
|
-
|
15
|
+
class DelegatedController < ActionController::Base
|
16
|
+
service_dispatching_mode :delegated
|
17
|
+
|
18
|
+
service(:test_service) { @service ||= Service.new; @service }
|
20
19
|
end
|
20
|
+
|
21
|
+
class DirectController < ActionController::Base
|
22
|
+
service_dispatching_mode :direct
|
21
23
|
|
22
|
-
|
23
|
-
|
24
|
+
attr :added
|
25
|
+
|
26
|
+
def add
|
27
|
+
@added = @params['a'] + @params['b']
|
28
|
+
end
|
29
|
+
|
30
|
+
export :add, :expects => [{:a=>Integer}, {:b=>Integer}], :returns => [Integer]
|
24
31
|
end
|
25
|
-
|
26
|
-
export :add, :expects => [Integer, Integer], :returns => [Integer]
|
27
|
-
export :find_people, :returns => [[ActionTestPerson]]
|
28
|
-
end
|
29
|
-
|
30
|
-
class ActionTestController < ActionController::Base
|
31
|
-
wsdl_service_name 'ActionTest'
|
32
|
-
service(:test_service) { ActionTestService.new }
|
33
32
|
end
|
34
33
|
|
35
|
-
class
|
36
|
-
def
|
37
|
-
@
|
34
|
+
class TC_RouterActionController < AbstractSoapTest
|
35
|
+
def test_direct_routing
|
36
|
+
@container = RouterActionControllerTest::DirectController.new
|
37
|
+
assert(do_soap_call('Add', 20, 50) == 70)
|
38
|
+
assert(@container.added == 70)
|
38
39
|
end
|
39
40
|
|
40
|
-
def
|
41
|
-
|
42
|
-
|
43
|
-
a = 20
|
44
|
-
b = 50
|
45
|
-
qname = XSD::QName.new('urn:ActionTest', public_method_name)
|
46
|
-
param_def = [
|
47
|
-
['in', 'param1', [SOAP::SOAPInt]],
|
48
|
-
['in', 'param2', [SOAP::SOAPString]],
|
49
|
-
]
|
50
|
-
request = SOAP::RPC::SOAPMethodRequest.new(qname, param_def)
|
51
|
-
request.set_param([
|
52
|
-
['param1', SOAP::Mapping.obj2soap(a)],
|
53
|
-
['param2', SOAP::Mapping.obj2soap(b)]
|
54
|
-
])
|
55
|
-
header = SOAP::SOAPHeader.new
|
56
|
-
body = SOAP::SOAPBody.new(request)
|
57
|
-
envelope = SOAP::SOAPEnvelope.new(header, body)
|
58
|
-
raw_request = SOAP::Processor.marshal(envelope)
|
59
|
-
test_request = ActionController::TestRequest.new
|
60
|
-
test_request.request_parameters['action'] = service_name
|
61
|
-
test_request.env['REQUEST_METHOD'] = "POST"
|
62
|
-
test_request.env['HTTP_CONTENT_TYPE'] = 'text/xml'
|
63
|
-
test_request.env['HTTP_SOAPACTION'] = "/soap/#{service_name}/#{public_method_name}"
|
64
|
-
test_request.env['RAW_POST_DATA'] = raw_request
|
65
|
-
test_response = ActionController::TestResponse.new
|
66
|
-
@controller.process(test_request, test_response)
|
67
|
-
raw_response = test_response.body
|
68
|
-
envelope = SOAP::Processor.unmarshal(raw_response)
|
69
|
-
assert(envelope.is_a?(SOAP::SOAPEnvelope))
|
70
|
-
resp = envelope.body.response
|
71
|
-
assert(resp.is_a?(SOAP::SOAPInt))
|
72
|
-
assert(resp.data == 70)
|
41
|
+
def test_direct_entrypoint
|
42
|
+
@container = RouterActionControllerTest::DirectController.new
|
43
|
+
assert(@container.respond_to?(:api))
|
73
44
|
end
|
74
45
|
|
75
|
-
def
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
request = SOAP::RPC::SOAPMethodRequest.new(qname)
|
80
|
-
header = SOAP::SOAPHeader.new
|
81
|
-
body = SOAP::SOAPBody.new(request)
|
82
|
-
envelope = SOAP::SOAPEnvelope.new(header, body)
|
83
|
-
raw_request = SOAP::Processor.marshal(envelope)
|
84
|
-
test_request = ActionController::TestRequest.new
|
85
|
-
test_request.request_parameters['action'] = service_name
|
86
|
-
test_request.env['REQUEST_METHOD'] = "POST"
|
87
|
-
test_request.env['HTTP_CONTENT_TYPE'] = 'text/xml'
|
88
|
-
test_request.env['HTTP_SOAPACTION'] = "/soap/#{service_name}/#{public_method_name}"
|
89
|
-
test_request.env['RAW_POST_DATA'] = raw_request
|
90
|
-
test_response = ActionController::TestResponse.new
|
91
|
-
@controller.process(test_request, test_response)
|
92
|
-
raw_response = test_response.body
|
93
|
-
envelope = SOAP::Processor.unmarshal(raw_response)
|
94
|
-
assert(envelope.is_a?(SOAP::SOAPEnvelope))
|
95
|
-
resp = envelope.body.response
|
96
|
-
assert(resp.is_a?(SOAP::SOAPFault))
|
46
|
+
def test_delegated_routing
|
47
|
+
@container = RouterActionControllerTest::DelegatedController.new
|
48
|
+
assert(do_soap_call('Add', 50, 80) == 130)
|
49
|
+
assert(service.added == 130)
|
97
50
|
end
|
51
|
+
|
52
|
+
|
53
|
+
protected
|
54
|
+
def service_name
|
55
|
+
@container.is_a?(RouterActionControllerTest::DelegatedController) ? 'test_service' : 'api'
|
56
|
+
end
|
57
|
+
|
58
|
+
def service
|
59
|
+
@container.service_object(:test_service)
|
60
|
+
end
|
61
|
+
|
62
|
+
def do_soap_call(public_method_name, *args)
|
63
|
+
super(public_method_name, *args) do |test_request, test_response|
|
64
|
+
response = @container.process(test_request, test_response)
|
65
|
+
end
|
66
|
+
end
|
98
67
|
end
|
data/test/router_wsdl_test.rb
CHANGED
@@ -1,37 +1,43 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/abstract_unit'
|
2
2
|
require 'wsdl/parser'
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
class WsdlTestService < ActionService::Base
|
12
|
-
def add(a, b)
|
13
|
-
a + b
|
4
|
+
module RouterWsdlTest
|
5
|
+
class Person < ActionService::Struct
|
6
|
+
member :id, Integer
|
7
|
+
member :names, [String]
|
8
|
+
member :lastname, String
|
9
|
+
member :deleted, TrueClass
|
14
10
|
end
|
15
|
-
|
16
|
-
|
17
|
-
|
11
|
+
|
12
|
+
class Service < ActionService::Base
|
13
|
+
def add(a, b)
|
14
|
+
a + b
|
15
|
+
end
|
16
|
+
|
17
|
+
def find_people
|
18
|
+
[]
|
19
|
+
end
|
20
|
+
|
21
|
+
def nil_returner
|
22
|
+
end
|
23
|
+
|
24
|
+
export :add, :expects => [{:a=>Integer}, {:b=>Integer}], :returns => [Integer]
|
25
|
+
export :find_people, :returns => [[Person]]
|
26
|
+
export :nil_returner
|
18
27
|
end
|
28
|
+
|
29
|
+
class WsdlController < ActionController::Base
|
30
|
+
service(:test_service) { Service.new }
|
19
31
|
|
20
|
-
|
32
|
+
def generate_wsdl(container, uri, soap_action_base)
|
33
|
+
to_wsdl(container, uri, soap_action_base)
|
34
|
+
end
|
21
35
|
end
|
22
|
-
|
23
|
-
export :add, :expects => [Integer, Integer], :returns => [Integer]
|
24
|
-
export :find_people, :returns => [[TestPerson]]
|
25
|
-
export :nil_returner
|
26
|
-
end
|
27
|
-
|
28
|
-
class WsdlController < ActionController::Base
|
29
|
-
service(:test_service) { WsdlTestService.new }
|
30
36
|
end
|
31
37
|
|
32
|
-
class
|
38
|
+
class TC_RouterWsdl < Test::Unit::TestCase
|
33
39
|
def test_wsdl_generation
|
34
|
-
wsdl = WsdlController.
|
40
|
+
wsdl = RouterWsdlTest::WsdlController.new.generate_wsdl(RouterWsdlTest::WsdlController.new, 'http://localhost:3000/test/', '/test')
|
35
41
|
assert(WSDL::Parser.new.parse(wsdl).is_a?(WSDL::Definitions))
|
36
42
|
end
|
37
43
|
|
@@ -39,7 +45,7 @@ class RouterWsdlTest < Test::Unit::TestCase
|
|
39
45
|
test_request = ActionController::TestRequest.new({ 'action' => 'wsdl' })
|
40
46
|
test_request.env['REQUEST_METHOD'] = 'GET'
|
41
47
|
test_request.env['HTTP_HOST'] = 'localhost:3000'
|
42
|
-
controller = WsdlController.new
|
48
|
+
controller = RouterWsdlTest::WsdlController.new
|
43
49
|
test_response = ActionController::TestResponse.new
|
44
50
|
controller.process(test_request, test_response)
|
45
51
|
assert(WSDL::Parser.new.parse(test_response.body).is_a?(WSDL::Definitions))
|