diff options
Diffstat (limited to 'actionwebservice/test/protocol_registry_test.rb')
-rw-r--r-- | actionwebservice/test/protocol_registry_test.rb | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/actionwebservice/test/protocol_registry_test.rb b/actionwebservice/test/protocol_registry_test.rb new file mode 100644 index 0000000000..8e2b9659a6 --- /dev/null +++ b/actionwebservice/test/protocol_registry_test.rb @@ -0,0 +1,53 @@ +require File.dirname(__FILE__) + '/abstract_unit' + + +module Foo + include ActionService::Protocol + + def self.append_features(base) + super + base.register_protocol(BodyOnly, FooMinimalProtocol) + base.register_protocol(HeaderAndBody, FooMinimalProtocolTwo) + base.register_protocol(HeaderAndBody, FooMinimalProtocolTwo) + base.register_protocol(HeaderAndBody, FooFullProtocol) + end + + class FooFullProtocol < AbstractProtocol + def self.create_protocol_request(klass, request) + protocol = FooFullProtocol.new klass + ActionService::Protocol::ProtocolRequest.new(protocol, '', '', '', '') + end + end + + class FooMinimalProtocol < AbstractProtocol + def self.create_protocol_request(klass, request) + protocol = FooMinimalProtocol.new klass + ActionService::Protocol::ProtocolRequest.new(protocol, '', '', '', '') + end + end + + class FooMinimalProtocolTwo < AbstractProtocol + end +end + +class ProtocolRegistry + include ActionService::Protocol::Registry + include Foo + + def all_protocols + header_and_body_protocols + body_only_protocols + end + + def protocol_request + probe_request_protocol(nil) + end +end + + +class TC_ProtocolRegistry < Test::Unit::TestCase + def test_registration + registry = ProtocolRegistry.new + assert(registry.all_protocols.length == 4) + assert(registry.protocol_request.protocol.is_a?(Foo::FooFullProtocol)) + end +end |