rack-amf 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,27 @@
1
+ require File.dirname(__FILE__) + '/../../spec_helper.rb'
2
+
3
+ describe AMF::Values::AbstractMessage do
4
+ before :each do
5
+ @message = AMF::Values::AbstractMessage.new
6
+ end
7
+
8
+ it "should generate conforming uuids" do
9
+ @message.rand_uuid.should =~ /[A-F0-9]{8}-[A-F0-9]{4}-[A-F0-9]{4}-[A-F0-9]{4}-[A-F0-9]{12}/i
10
+ end
11
+ end
12
+
13
+ describe AMF::Values::ErrorMessage do
14
+ before :each do
15
+ @e = Exception.new('Error message')
16
+ @e.set_backtrace(['Backtrace 1', 'Backtrace 2'])
17
+ @message = AMF::Values::ErrorMessage.new(nil, @e)
18
+ end
19
+
20
+ it "should serialize as a hash in AMF0"
21
+
22
+ it "should extract exception properties correctly" do
23
+ @message.faultCode.should == 'Exception'
24
+ @message.faultString.should == 'Error message'
25
+ @message.faultDetail.should == "Backtrace 1\nBacktrace 2"
26
+ end
27
+ end
@@ -0,0 +1,5 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper.rb'
2
+ require 'rack/amf'
3
+
4
+ describe Rack::AMF::Request do
5
+ end
@@ -0,0 +1,46 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper.rb'
2
+ require 'rack/amf'
3
+
4
+ describe Rack::AMF::Response do
5
+ it "should serialize response when converted to string" do
6
+ response = Rack::AMF::Response.new(create_rack_request('commandMessage.bin'))
7
+ response.raw_response.should_receive(:serialize).and_return('serialized')
8
+ response.to_s.should == 'serialized'
9
+ end
10
+
11
+ it "should respond to ping command" do
12
+ response = Rack::AMF::Response.new(create_rack_request('commandMessage.bin'))
13
+ response.each_method_call {|method, args| nil}
14
+
15
+ r = response.raw_response
16
+ r.messages.length.should == 1
17
+ r.messages[0].data.should be_a(AMF::Values::AcknowledgeMessage)
18
+ end
19
+
20
+ it "should handle RemotingMessages properly" do
21
+ response = Rack::AMF::Response.new(create_rack_request('remotingMessage.bin'))
22
+
23
+ response.each_method_call do |method, args|
24
+ method.should == 'WritesController.save'
25
+ args.should == [true]
26
+ true
27
+ end
28
+
29
+ r = response.raw_response
30
+ r.messages.length.should == 1
31
+ r.messages[0].data.should be_a(AMF::Values::AcknowledgeMessage)
32
+ r.messages[0].data.body.should == true
33
+ end
34
+
35
+ it "should catch exceptions properly" do
36
+ response = Rack::AMF::Response.new(create_rack_request('remotingMessage.bin'))
37
+ response.each_method_call do |method, args|
38
+ raise 'Error in call'
39
+ end
40
+
41
+ r = response.raw_response
42
+ r.messages.length.should == 1
43
+ r.messages[0].data.should be_a(AMF::Values::ErrorMessage)
44
+ r.messages[0].target_uri.should =~ /onStatus$/
45
+ end
46
+ end
@@ -0,0 +1,26 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper.rb'
2
+ require 'rack/amf'
3
+
4
+ describe Rack::AMF::ServiceManager do
5
+ before :each do
6
+ @manager = Rack::AMF::ServiceManager.new
7
+ end
8
+
9
+ it "should support mapped services" do
10
+ service = mock "Service"
11
+ @manager.register('path.Service', service)
12
+ service.should_receive('respond_to?').with('test').and_return(true)
13
+ service.should_receive('test').with('arg1', 'arg2').and_return('success')
14
+
15
+ @manager.send(:handle_method, 'path.Service.test', ['arg1', 'arg2']).should == 'success'
16
+ end
17
+
18
+ it "should map '' to no path method calls" do
19
+ service = mock "Service"
20
+ @manager.register('', service)
21
+ service.should_receive('respond_to?').with('test').and_return(true)
22
+ service.should_receive('test').and_return('success')
23
+
24
+ @manager.send(:handle_method, 'test', []).should == 'success'
25
+ end
26
+ end
@@ -0,0 +1,24 @@
1
+ begin
2
+ require 'spec'
3
+ rescue LoadError
4
+ require 'rubygems'
5
+ gem 'rspec'
6
+ require 'spec'
7
+ end
8
+ require 'spec/autorun'
9
+
10
+ $:.unshift(File.dirname(__FILE__) + '/../lib')
11
+ require 'amf'
12
+
13
+ def request_fixture(binary_path)
14
+ File.open(File.dirname(__FILE__) + '/fixtures/request/' + binary_path).read
15
+ end
16
+
17
+ def object_fixture(binary_path)
18
+ File.open(File.dirname(__FILE__) + '/fixtures/objects/' + binary_path).read
19
+ end
20
+
21
+ def create_rack_request(binary_path)
22
+ env = {'rack.input' => StringIO.new(request_fixture(binary_path))}
23
+ Rack::AMF::Request.new(env)
24
+ end
metadata ADDED
@@ -0,0 +1,97 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rack-amf
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Tony Hillerson
8
+ - Stephen Augenstein
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2009-10-03 00:00:00 -04:00
14
+ default_executable:
15
+ dependencies: []
16
+
17
+ description:
18
+ email: perl.programmer@gmail.com
19
+ executables: []
20
+
21
+ extensions: []
22
+
23
+ extra_rdoc_files:
24
+ - README.rdoc
25
+ files:
26
+ - README.rdoc
27
+ - Rakefile
28
+ - lib/amf/class_mapping.rb
29
+ - lib/amf/common.rb
30
+ - lib/amf/constants.rb
31
+ - lib/amf/pure/deserializer.rb
32
+ - lib/amf/pure/io_helpers.rb
33
+ - lib/amf/pure/remoting.rb
34
+ - lib/amf/pure/serializer.rb
35
+ - lib/amf/pure.rb
36
+ - lib/amf/values/array_collection.rb
37
+ - lib/amf/values/messages.rb
38
+ - lib/amf/values/typed_hash.rb
39
+ - lib/amf/version.rb
40
+ - lib/amf.rb
41
+ - lib/rack/amf/application.rb
42
+ - lib/rack/amf/request.rb
43
+ - lib/rack/amf/response.rb
44
+ - lib/rack/amf/service_manager.rb
45
+ - lib/rack/amf.rb
46
+ - spec/amf/class_mapping_set_spec.rb
47
+ - spec/amf/class_mapping_spec.rb
48
+ - spec/amf/deserializer_spec.rb
49
+ - spec/amf/remoting_spec.rb
50
+ - spec/amf/serializer_spec.rb
51
+ - spec/amf/values/array_collection_spec.rb
52
+ - spec/amf/values/messages_spec.rb
53
+ - spec/rack/request_spec.rb
54
+ - spec/rack/response_spec.rb
55
+ - spec/rack/service_manager_spec.rb
56
+ - spec/spec_helper.rb
57
+ has_rdoc: true
58
+ homepage: http://github.com/warhammerkid/rack-amf
59
+ licenses: []
60
+
61
+ post_install_message:
62
+ rdoc_options:
63
+ - --line-numbers
64
+ - --main
65
+ - README.rdoc
66
+ require_paths:
67
+ - lib
68
+ required_ruby_version: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ version: "0"
73
+ version:
74
+ required_rubygems_version: !ruby/object:Gem::Requirement
75
+ requirements:
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ version: "0"
79
+ version:
80
+ requirements: []
81
+
82
+ rubyforge_project:
83
+ rubygems_version: 1.3.5
84
+ signing_key:
85
+ specification_version: 3
86
+ summary: AMF serializer/deserializer and AMF gateway packaged as a rack middleware
87
+ test_files:
88
+ - spec/amf/class_mapping_set_spec.rb
89
+ - spec/amf/class_mapping_spec.rb
90
+ - spec/amf/deserializer_spec.rb
91
+ - spec/amf/remoting_spec.rb
92
+ - spec/amf/serializer_spec.rb
93
+ - spec/amf/values/array_collection_spec.rb
94
+ - spec/amf/values/messages_spec.rb
95
+ - spec/rack/request_spec.rb
96
+ - spec/rack/response_spec.rb
97
+ - spec/rack/service_manager_spec.rb