actionwebservice 0.6.2 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +21 -0
- data/README +50 -6
- data/Rakefile +9 -9
- data/TODO +6 -6
- data/lib/action_web_service.rb +4 -3
- data/lib/action_web_service/api.rb +248 -1
- data/lib/action_web_service/casting.rb +111 -0
- data/lib/action_web_service/client/soap_client.rb +17 -33
- data/lib/action_web_service/client/xmlrpc_client.rb +10 -34
- data/lib/action_web_service/container/delegated_container.rb +1 -1
- data/lib/action_web_service/dispatcher/abstract.rb +52 -72
- data/lib/action_web_service/dispatcher/action_controller_dispatcher.rb +71 -55
- data/lib/action_web_service/protocol/abstract.rb +82 -3
- data/lib/action_web_service/protocol/discovery.rb +2 -2
- data/lib/action_web_service/protocol/soap_protocol.rb +95 -22
- data/lib/action_web_service/protocol/soap_protocol/marshaler.rb +197 -0
- data/lib/action_web_service/protocol/xmlrpc_protocol.rb +56 -24
- data/lib/action_web_service/scaffolding.rb +237 -0
- data/lib/action_web_service/struct.rb +17 -4
- data/lib/action_web_service/support/signature_types.rb +194 -0
- data/lib/action_web_service/templates/scaffolds/layout.rhtml +65 -0
- data/lib/action_web_service/templates/scaffolds/methods.rhtml +6 -0
- data/lib/action_web_service/templates/scaffolds/parameters.rhtml +28 -0
- data/lib/action_web_service/templates/scaffolds/result.rhtml +30 -0
- data/lib/action_web_service/test_invoke.rb +23 -42
- data/test/abstract_dispatcher.rb +102 -48
- data/test/abstract_unit.rb +1 -1
- data/test/api_test.rb +40 -7
- data/test/casting_test.rb +82 -0
- data/test/client_soap_test.rb +3 -0
- data/test/client_xmlrpc_test.rb +5 -1
- data/test/dispatcher_action_controller_soap_test.rb +9 -12
- data/test/dispatcher_action_controller_xmlrpc_test.rb +1 -11
- data/test/run +1 -0
- data/test/scaffolded_controller_test.rb +67 -0
- data/test/struct_test.rb +33 -21
- data/test/test_invoke_test.rb +1 -1
- metadata +18 -31
- data/lib/action_web_service/api/base.rb +0 -135
- data/lib/action_web_service/vendor/ws.rb +0 -4
- data/lib/action_web_service/vendor/ws/common.rb +0 -8
- data/lib/action_web_service/vendor/ws/encoding.rb +0 -3
- data/lib/action_web_service/vendor/ws/encoding/abstract.rb +0 -26
- data/lib/action_web_service/vendor/ws/encoding/soap_rpc_encoding.rb +0 -90
- data/lib/action_web_service/vendor/ws/encoding/xmlrpc_encoding.rb +0 -53
- data/lib/action_web_service/vendor/ws/marshaling.rb +0 -3
- data/lib/action_web_service/vendor/ws/marshaling/abstract.rb +0 -17
- data/lib/action_web_service/vendor/ws/marshaling/soap_marshaling.rb +0 -277
- data/lib/action_web_service/vendor/ws/marshaling/xmlrpc_marshaling.rb +0 -116
- data/lib/action_web_service/vendor/ws/types.rb +0 -165
- data/test/ws/abstract_encoding.rb +0 -68
- data/test/ws/abstract_unit.rb +0 -13
- data/test/ws/gencov +0 -3
- data/test/ws/run +0 -5
- data/test/ws/soap_marshaling_test.rb +0 -91
- data/test/ws/soap_rpc_encoding_test.rb +0 -47
- data/test/ws/types_test.rb +0 -43
- data/test/ws/xmlrpc_encoding_test.rb +0 -34
@@ -1,47 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/abstract_encoding'
|
2
|
-
require 'time'
|
3
|
-
|
4
|
-
class SoapRpcEncodingTest < Test::Unit::TestCase
|
5
|
-
include EncodingTest
|
6
|
-
|
7
|
-
def test_setup
|
8
|
-
@encoder = WS::Encoding::SoapRpcEncoding.new
|
9
|
-
@marshaler = WS::Marshaling::SoapMarshaler.new
|
10
|
-
end
|
11
|
-
|
12
|
-
def test_call_encoding_and_decoding
|
13
|
-
obj = encode_rpc_call('DecodeMe', @call_signature, @call_params)
|
14
|
-
method_name, decoded_params = decode_rpc_call(obj)
|
15
|
-
params = decoded_params.map{|x| @marshaler.unmarshal(x).value}
|
16
|
-
assert_equal(method_name, 'DecodeMe')
|
17
|
-
assert_equal(@call_params[0..3], params[0..3])
|
18
|
-
# XXX: DateTime not marshaled correctly yet
|
19
|
-
assert_equal(@call_params[5..-1], params[5..-1])
|
20
|
-
end
|
21
|
-
|
22
|
-
def test_response_encoding_and_decoding_simple
|
23
|
-
obj = encode_rpc_response('DecodeMe', @response_signature, @response_param)
|
24
|
-
method_name, return_value = decode_rpc_response(obj)
|
25
|
-
return_value = @marshaler.unmarshal(return_value).value
|
26
|
-
assert_equal('DecodeMe', method_name)
|
27
|
-
assert_equal(@response_param, return_value)
|
28
|
-
end
|
29
|
-
|
30
|
-
def test_response_encoding_and_decoding_struct
|
31
|
-
struct = Nested::StructClass.new
|
32
|
-
obj = encode_rpc_response('DecodeMe', [Nested::StructClass], struct)
|
33
|
-
method_name, return_value = decode_rpc_response(obj)
|
34
|
-
return_value = @marshaler.unmarshal(return_value).value
|
35
|
-
assert_equal('DecodeMe', method_name)
|
36
|
-
assert_equal(struct, return_value)
|
37
|
-
end
|
38
|
-
|
39
|
-
def test_response_encoding_and_decoding_array
|
40
|
-
struct = Nested::StructClass.new
|
41
|
-
obj = encode_rpc_response('DecodeMe', [[Nested::StructClass]], [struct])
|
42
|
-
method_name, return_value = decode_rpc_response(obj)
|
43
|
-
return_value = @marshaler.unmarshal(return_value).value
|
44
|
-
assert_equal('DecodeMe', method_name)
|
45
|
-
assert_equal([struct], return_value)
|
46
|
-
end
|
47
|
-
end
|
data/test/ws/types_test.rb
DELETED
@@ -1,43 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/abstract_unit'
|
2
|
-
|
3
|
-
class TypesTest < Test::Unit::TestCase
|
4
|
-
include WS
|
5
|
-
|
6
|
-
def setup
|
7
|
-
@caster = BaseTypeCaster.new
|
8
|
-
end
|
9
|
-
|
10
|
-
def test_base_types
|
11
|
-
assert_equal(:int, BaseTypes.canonical_type_name(:integer))
|
12
|
-
assert_equal(:int, BaseTypes.canonical_type_name(:fixnum))
|
13
|
-
assert_equal(Integer, BaseTypes.type_name_to_class(:bignum))
|
14
|
-
assert_equal(Date, BaseTypes.type_name_to_class(:date))
|
15
|
-
assert_equal(Time, BaseTypes.type_name_to_class(:timestamp))
|
16
|
-
assert_equal(TrueClass, BaseTypes.type_name_to_class(:bool))
|
17
|
-
assert_equal(:int, BaseTypes.class_to_type_name(Bignum))
|
18
|
-
assert_equal(:bool, BaseTypes.class_to_type_name(FalseClass))
|
19
|
-
assert_equal(Integer, BaseTypes.canonical_type_class(Fixnum))
|
20
|
-
assert_raises(TypeError) do
|
21
|
-
BaseTypes.canonical_type_name(:fake)
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
def test_casting
|
26
|
-
assert_equal(5, @caster.cast("5", Fixnum))
|
27
|
-
assert_equal('50.0', @caster.cast(50.0, String))
|
28
|
-
assert_equal(true, @caster.cast('true', FalseClass))
|
29
|
-
assert_equal(false, @caster.cast('false', TrueClass))
|
30
|
-
assert_equal(true, @caster.cast(1, FalseClass))
|
31
|
-
assert_equal(false, @caster.cast(0, TrueClass))
|
32
|
-
assert_raises(TypeError) do
|
33
|
-
@caster.cast('yes', FalseClass)
|
34
|
-
end
|
35
|
-
assert_equal(3.14159, @caster.cast('3.14159', Float))
|
36
|
-
now1 = Time.new
|
37
|
-
now2 = @caster.cast("#{now1}", Time)
|
38
|
-
assert_equal(now1.tv_sec, now2.tv_sec)
|
39
|
-
date1 = Date.parse('2004-01-01')
|
40
|
-
date2 = @caster.cast("#{date1}", Date)
|
41
|
-
assert_equal(date1, date2)
|
42
|
-
end
|
43
|
-
end
|
@@ -1,34 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/abstract_encoding'
|
2
|
-
require 'time'
|
3
|
-
|
4
|
-
class XmlRpcEncodingTest < Test::Unit::TestCase
|
5
|
-
include EncodingTest
|
6
|
-
|
7
|
-
def test_setup
|
8
|
-
@encoder = WS::Encoding::XmlRpcEncoding.new
|
9
|
-
@marshaler = WS::Marshaling::XmlRpcMarshaler.new
|
10
|
-
end
|
11
|
-
|
12
|
-
def test_typed_call_encoding_and_decoding
|
13
|
-
obj = encode_rpc_call('DecodeMe', @call_signature, @call_params)
|
14
|
-
method_name, params = decode_rpc_call(obj)
|
15
|
-
(0..(@call_signature.length-1)).each do |i|
|
16
|
-
params[i] = @marshaler.typed_unmarshal(params[i], @call_signature[i]).value
|
17
|
-
end
|
18
|
-
assert_equal(method_name, 'DecodeMe')
|
19
|
-
assert_equal(@call_params[0..3], params[0..3])
|
20
|
-
assert_equal(@call_params[5..-1], params[5..-1])
|
21
|
-
end
|
22
|
-
|
23
|
-
def test_untyped_call_encoding_and_decoding
|
24
|
-
obj = encode_rpc_call('DecodeMe', @call_signature, @call_params)
|
25
|
-
method_name, params = decode_rpc_call(obj)
|
26
|
-
(0..(@call_signature.length-1)).each do |i|
|
27
|
-
params[i] = @marshaler.unmarshal(params[i]).value
|
28
|
-
end
|
29
|
-
assert_equal(method_name, 'DecodeMe')
|
30
|
-
assert_equal(@call_params[0..3], params[0..3])
|
31
|
-
assert_equal(@call_params[5].name, params[5]['name'])
|
32
|
-
assert_equal(@call_params[5].version, params[5]['version'])
|
33
|
-
end
|
34
|
-
end
|