neerfri-ramf 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/LICENSE +166 -0
- data/README +3 -0
- data/Rakefile +17 -0
- data/lib/ramf/amf_header.rb +9 -0
- data/lib/ramf/amf_message.rb +26 -0
- data/lib/ramf/amf_object.rb +54 -0
- data/lib/ramf/configuration.rb +8 -0
- data/lib/ramf/default_operation_processor.rb +20 -0
- data/lib/ramf/deserializer/amf0_reader.rb +61 -0
- data/lib/ramf/deserializer/amf3_reader.rb +242 -0
- data/lib/ramf/deserializer/base.rb +76 -0
- data/lib/ramf/deserializer.rb +9 -0
- data/lib/ramf/extensions/class.rb +139 -0
- data/lib/ramf/extensions/exception.rb +3 -0
- data/lib/ramf/extensions/hash.rb +8 -0
- data/lib/ramf/extensions/object.rb +44 -0
- data/lib/ramf/flex_class_traits.rb +98 -0
- data/lib/ramf/flex_objects/acknowledge_message.rb +31 -0
- data/lib/ramf/flex_objects/byte_array.rb +9 -0
- data/lib/ramf/flex_objects/command_message.rb +86 -0
- data/lib/ramf/flex_objects/error_message.rb +14 -0
- data/lib/ramf/flex_objects/flex_anonymous_object.rb +37 -0
- data/lib/ramf/flex_objects/flex_object.rb +13 -0
- data/lib/ramf/flex_objects/remoting_message.rb +26 -0
- data/lib/ramf/io/common_read_write.rb +73 -0
- data/lib/ramf/io/constants.rb +79 -0
- data/lib/ramf/io/flex_class_signature.rb +16 -0
- data/lib/ramf/io/place_holder.rb +8 -0
- data/lib/ramf/io/reference_table.rb +74 -0
- data/lib/ramf/operation_processors_manager.rb +30 -0
- data/lib/ramf/operation_request.rb +51 -0
- data/lib/ramf/serializer/amf0_writer.rb +89 -0
- data/lib/ramf/serializer/amf3_writer.rb +193 -0
- data/lib/ramf/serializer/base.rb +57 -0
- data/lib/ramf/serializer.rb +9 -0
- data/lib/ramf/util.rb +34 -0
- data/lib/ramf.rb +62 -0
- data/spec/amf_object_spec.rb +85 -0
- data/spec/deserializer_spec.rb +22 -0
- data/spec/examples/examples_helper.rb +75 -0
- data/spec/examples/remoting_login_spec.rb +53 -0
- data/spec/examples/simple_amf_spec.rb +55 -0
- data/spec/examples/simple_remoting_spec.rb +60 -0
- data/spec/extensions/class_extensions_spec.rb +62 -0
- data/spec/fixtures/catalog.yml +5 -0
- data/spec/fixtures/deserializer1.bin +0 -0
- data/spec/fixtures/deserializer1.rb +31 -0
- data/spec/fixtures/deserializer2.bin +0 -0
- data/spec/fixtures/deserializer2.rb +40 -0
- data/spec/fixtures/deserializer3.bin +0 -0
- data/spec/fixtures/ping_command_message.amf +0 -0
- data/spec/fixtures/remoting_login_operation.amf +0 -0
- data/spec/fixtures/simple_remoting_message.amf +0 -0
- data/spec/flex_class_traits_spec.rb +52 -0
- data/spec/inherited_class_traits_spec.rb +58 -0
- data/spec/io/reference_table_spec.rb +38 -0
- data/spec/operation_processors_manager_spec.rb +61 -0
- data/spec/serializer/amf3_writer_spec.rb +565 -0
- data/spec/serializer/base_spec.rb +92 -0
- data/spec/serializer/full_spec.rb +172 -0
- data/spec/spec_helper.rb +28 -0
- metadata +153 -0
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
require File.join(File.dirname(__FILE__),'spec_helper')
|
|
2
|
+
|
|
3
|
+
describe RAMF::AMFObject do
|
|
4
|
+
before(:each) do
|
|
5
|
+
@amf_object = RAMF::AMFObject.new
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
describe "process method" do
|
|
9
|
+
before(:each) do
|
|
10
|
+
@operation1 = stub("OperationRequest1")
|
|
11
|
+
@operation2 = stub("OperationRequest2")
|
|
12
|
+
@message1 = stub("AMFMessage", :to_operation=>@operation1, :response_uri=>"1")
|
|
13
|
+
@message2 = stub("AMFMessage", :to_operation=>@operation2, :response_uri=>"2")
|
|
14
|
+
@amf_object.add_message(@message1)
|
|
15
|
+
@amf_object.add_message(@message2)
|
|
16
|
+
RAMF::OperationProcessorsManager.stub!(:process).with(@operation1).and_return(1)
|
|
17
|
+
RAMF::OperationProcessorsManager.stub!(:process).with(@operation2).and_return(2)
|
|
18
|
+
@method = @amf_object.method(:process)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
it 'should pass additional arguments to OperationProcessorsManager#process' do
|
|
22
|
+
@arg1 = mock("arg1"); @arg2 = mock("arg2")
|
|
23
|
+
RAMF::OperationProcessorsManager.should_receive(:process).with(@operation1, @arg1, @arg2)
|
|
24
|
+
RAMF::OperationProcessorsManager.should_receive(:process).with(@operation2, @arg1, @arg2)
|
|
25
|
+
@method.call(@arg1, @arg2)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
it "should call RAMF::OperationProcessor.process to process the OperationRequest" do
|
|
29
|
+
RAMF::OperationProcessorsManager.should_receive(:process).with(@operation1)
|
|
30
|
+
RAMF::OperationProcessorsManager.should_receive(:process).with(@operation2)
|
|
31
|
+
@method.call
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
describe "returned value" do
|
|
35
|
+
it "should be an instance of AMFObject" do
|
|
36
|
+
@method.call.should be_an_instance_of(RAMF::AMFObject)
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
it "should contain same number of messages" do
|
|
40
|
+
@method.call.messages.size.should == 2
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
it 'should contain message with target_uri "1/onResult" with the right value' do
|
|
44
|
+
message = @method.call.messages.find{|m| m.target_uri == "1/onResult"}
|
|
45
|
+
message.should_not be_nil
|
|
46
|
+
message.value.should == 1
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
it 'should contain message with target_uri "2/onResult" with the right value' do
|
|
50
|
+
message = @method.call.messages.find{|m| m.target_uri == "2/onResult"}
|
|
51
|
+
message.should_not be_nil
|
|
52
|
+
message.value.should == 2
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
it "should contain one message with Exception when exception was raised in processing" do
|
|
56
|
+
exception = RAMF::OperationProcessorsManager::ErrorWhileProcessing.new("", StandardError.new)
|
|
57
|
+
RAMF::OperationProcessorsManager.should_receive(:process).with(@operation1).and_raise(exception)
|
|
58
|
+
@operation1.should_receive(:exception_response).and_return(StandardError.new)
|
|
59
|
+
messages = @method.call.messages.select{|m| m.target_uri[-8,8] == "onStatus"}
|
|
60
|
+
messages.size.should == 1
|
|
61
|
+
messages.first.should_not be_nil
|
|
62
|
+
messages.first.value.should be_an_instance_of(StandardError)
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
end #process method
|
|
67
|
+
|
|
68
|
+
describe "credentials_header method" do
|
|
69
|
+
before(:each) do
|
|
70
|
+
@method = @amf_object.method(:credentials_header)
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
describe "returned value" do
|
|
74
|
+
it "should be {:userid => nil, :password => nil}" do
|
|
75
|
+
@method.call.should == {:userid => nil, :password => nil}
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
it "should be {:userid => 'my_user', :password => 'my_password'}" do
|
|
79
|
+
@amf_object.add_header(stub("AMFHeader", :name=>"Credentials", :value=>{:userid=>'my_user', :password => 'my_password'}))
|
|
80
|
+
@method.call.should == {:userid => 'my_user', :password => 'my_password'}
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
end
|
|
84
|
+
end #credentials_header method
|
|
85
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
require File.join(File.dirname(__FILE__),'spec_helper')
|
|
2
|
+
|
|
3
|
+
describe RAMF::Deserializer do
|
|
4
|
+
|
|
5
|
+
describe RAMF::Deserializer::Base do
|
|
6
|
+
1.upto(2) do |i|
|
|
7
|
+
File.open(File.join(AMF_EXAMPLE_DIR,"deserializer#{i}.rb"),"r") {|f| eval(f.read)}
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
it 'should return an RAMF::AMFObject after process' do
|
|
11
|
+
deserialize_from_file('deserializer1.bin').should be_an_instance_of(RAMF::AMFObject)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def deserialize_from_file(filename)
|
|
17
|
+
File.open(File.join(AMF_EXAMPLE_DIR,filename),'r') do |f|
|
|
18
|
+
deserializer = RAMF::Deserializer::Base.new(f)
|
|
19
|
+
deserializer.process
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
module ExampleHelper
|
|
2
|
+
|
|
3
|
+
class OperationProcessor
|
|
4
|
+
def self.will_process?(operation)
|
|
5
|
+
true
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def self.process(operation)
|
|
9
|
+
#this is used to check the existence of credentials
|
|
10
|
+
credentials = operation.credentials[:userid] ? "with credentials #{operation.credentials.inspect}" : "without credentials"
|
|
11
|
+
if operation.login?
|
|
12
|
+
#check handling of login operation requests
|
|
13
|
+
"Logging in " << credentials
|
|
14
|
+
elsif operation.remoting_message?
|
|
15
|
+
#check handling of remoting messages
|
|
16
|
+
"RemotingMessage: #{operation.service}.#{operation.method} " << credentials
|
|
17
|
+
else
|
|
18
|
+
#check handling of simpele amf (non messaging)
|
|
19
|
+
"SimpleAMF: #{operation.service}.#{operation.method} " << credentials
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def incoming_amf_object_examples(options = {})
|
|
25
|
+
options = {:headers=>0, :messages=>1}.merge(options)
|
|
26
|
+
it('should be_an_instance_of(AMFObject)') {@incoming_amf_object.should be_an_instance_of(AMFObject)}
|
|
27
|
+
it('should have ' + options[:headers].to_s + ' headers') {@incoming_amf_object.headers.size.should == options[:headers]}
|
|
28
|
+
it('should have ' + options[:messages].to_s + ' message') { @incoming_amf_object.messages.size.should == options[:messages] }
|
|
29
|
+
it('should declare amf version 0') { @incoming_amf_object.version.should == 0 }
|
|
30
|
+
it('should declare client 3') { @incoming_amf_object.client.should == 3 }
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def incoming_amf_object_message_examples(options = {})
|
|
34
|
+
it('should be an instance of AMFMessage') { @message.should be_an_instance_of(AMFMessage) }
|
|
35
|
+
it('should declare amf version 3') { @message.amf_version.should == 3 }
|
|
36
|
+
it('should declare response uri ' + options[:response_uri].inspect) { @message.response_uri.should == options[:response_uri] }
|
|
37
|
+
it('should declare length '+ options[:length].inspect) { @message.length.should == options[:length] }
|
|
38
|
+
it('should declare target_uri ' + options[:target_uri].inspect) { @message.target_uri.should == options[:target_uri] }
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def incoming_amf_object_message_value_examples(options = {})
|
|
42
|
+
it('should be an instance of '+options[:class].name) { @value.should be_an_instance_of(options[:class]) }
|
|
43
|
+
it('should declare timestamp 0') { @value.timestamp.should == 0 }
|
|
44
|
+
it('should declare headers '+options[:headers].inspect){ @value.headers.should == options[:headers] }
|
|
45
|
+
it('should declare clientId nil') { @value.clientId.should == nil }
|
|
46
|
+
it('should declare timeToLive 0') { @value.timeToLive.should == 0 }
|
|
47
|
+
it('should declare messageId ' + options[:messageId].inspect) { @value.messageId.should == options[:messageId] }
|
|
48
|
+
it('should declare body '+options[:body].inspect) { @value.body.should == options[:body] }
|
|
49
|
+
it('should declare destination '+options[:destination].inspect) { @value.destination.should == options[:destination] }
|
|
50
|
+
it('should declare operation '+options[:operation].inspect) { @value.operation.should == options[:operation] }
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def processed_incoming_amf_object_examples(options = {})
|
|
54
|
+
it('should be an instance of AMFObject') {@processed_incoming_amf_object.should be_an_instance_of(AMFObject)}
|
|
55
|
+
it('should declare version 0') {@processed_incoming_amf_object.version.should == 0}
|
|
56
|
+
it('should declare client 3') {@processed_incoming_amf_object.client.should == 3}
|
|
57
|
+
it('should declare headers []') {@processed_incoming_amf_object.headers.should == []}
|
|
58
|
+
it('should have 1 message') {@processed_incoming_amf_object.messages.size.should == 1}
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def processed_incoming_amf_object_message_examples(options = {})
|
|
62
|
+
it('should be an instance of AMFMessage') {@message.should be_an_instance_of(AMFMessage)}
|
|
63
|
+
it('should declare amf_version 3') {@message.amf_version.should == 3}
|
|
64
|
+
it('should declare length -1') {@message.length.should == -1}
|
|
65
|
+
it('should declare response_uri ""') {@message.response_uri.should == ""}
|
|
66
|
+
it('should declare target_uri '+options[:target_uri].inspect) {@message.target_uri.should == options[:target_uri]}
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def processed_incoming_amf_object_message_value_examples(options = {})
|
|
70
|
+
it('should be an instance of FlexObjects::AcknowledgeMessage') {@value.should be_an_instance_of(FlexObjects::AcknowledgeMessage)}
|
|
71
|
+
it('should declare body '+options[:body].inspect) {@value.body.should == options[:body] }
|
|
72
|
+
it('should declare correlationId '+options[:correlationId].inspect) {@value.correlationId.should == options[:correlationId] }
|
|
73
|
+
it('should declare messageId in the right form') {@value.messageId.should =~ /^.{8}-.{4}-.{4}-.{4}-.{12}$/ }
|
|
74
|
+
end
|
|
75
|
+
end
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
require File.join(File.dirname(__FILE__),'../spec_helper')
|
|
2
|
+
require File.join(File.dirname(__FILE__),'examples_helper')
|
|
3
|
+
include RAMF
|
|
4
|
+
include ExampleHelper
|
|
5
|
+
|
|
6
|
+
describe "RAMF" do
|
|
7
|
+
|
|
8
|
+
describe "remoting_login" do
|
|
9
|
+
before(:all) do
|
|
10
|
+
work_with_example(:remoting_login_operation) do |f|
|
|
11
|
+
@deserializer = Deserializer::Base.new(f)
|
|
12
|
+
@incoming_amf_object = @deserializer.process
|
|
13
|
+
OperationProcessorsManager.add_operation_processor(ExampleHelper::OperationProcessor)
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
describe "incoming_amf_object" do
|
|
18
|
+
incoming_amf_object_examples
|
|
19
|
+
|
|
20
|
+
describe "message" do
|
|
21
|
+
before(:all) { @message = @incoming_amf_object.messages.first}
|
|
22
|
+
incoming_amf_object_message_examples(:response_uri=>"/1", :length=>251,:target_uri=>"null")
|
|
23
|
+
|
|
24
|
+
describe "value" do
|
|
25
|
+
before(:all) {@value = @message.value.first}
|
|
26
|
+
incoming_amf_object_message_value_examples(:class=>FlexObjects::CommandMessage,
|
|
27
|
+
:headers=>{:DSId=>"nil", :DSMessagingVersion=>1},
|
|
28
|
+
:messageId=>"231F8134-8454-9184-252F-F6ED9FF51A01",
|
|
29
|
+
:body=>"bXlVc2VybmFtZTpteVBhc3N3b3Jk",
|
|
30
|
+
:destination=>"",
|
|
31
|
+
:operation=>8)
|
|
32
|
+
|
|
33
|
+
end #RAMF remoting_login incoming_amf_object message value
|
|
34
|
+
end #RAMF remoting_login incoming_amf_object message
|
|
35
|
+
|
|
36
|
+
describe "processed_incoming_amf_object" do
|
|
37
|
+
before(:all) {@processed_incoming_amf_object = @incoming_amf_object.process}
|
|
38
|
+
processed_incoming_amf_object_examples
|
|
39
|
+
|
|
40
|
+
describe "message" do
|
|
41
|
+
before(:all) {@message = @processed_incoming_amf_object.messages.first}
|
|
42
|
+
processed_incoming_amf_object_message_examples(:target_uri=>"/1/onResult")
|
|
43
|
+
|
|
44
|
+
describe "value" do
|
|
45
|
+
before(:all) {@value = @message.value}
|
|
46
|
+
processed_incoming_amf_object_message_value_examples(:body=>"Logging in with credentials #{{:password=>"myPassword", :userid=>"myUsername"}.inspect}",
|
|
47
|
+
:correlationId=>"231F8134-8454-9184-252F-F6ED9FF51A01")
|
|
48
|
+
end
|
|
49
|
+
end #RAMF remoting_login incoming_amf_object processed_incoming_amf_object message
|
|
50
|
+
end #RAMF remoting_login incoming_amf_object processed_incoming_amf_object
|
|
51
|
+
end #RAMF remoting_login incoming_amf_object
|
|
52
|
+
end #RAMF remoting_login
|
|
53
|
+
end #RAMF
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
require File.join(File.dirname(__FILE__),'../spec_helper')
|
|
2
|
+
require File.join(File.dirname(__FILE__),'examples_helper')
|
|
3
|
+
include RAMF
|
|
4
|
+
include ExampleHelper
|
|
5
|
+
|
|
6
|
+
describe "RAMF" do
|
|
7
|
+
|
|
8
|
+
#This is a simple amf request (not messaging) with credentials supplied in the headers of the AMFObject
|
|
9
|
+
describe "simple_amf1" do
|
|
10
|
+
|
|
11
|
+
before(:all) do
|
|
12
|
+
work_with_example(:simple_amf1) do |f|
|
|
13
|
+
@deserializer = Deserializer::Base.new(f)
|
|
14
|
+
@incoming_amf_object = @deserializer.process
|
|
15
|
+
OperationProcessorsManager.add_operation_processor(ExampleHelper::OperationProcessor)
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
describe "incoming_amf_object" do
|
|
20
|
+
incoming_amf_object_examples(:headers=>1, :messages=>1)
|
|
21
|
+
|
|
22
|
+
describe "first_header" do
|
|
23
|
+
before(:all) {@header = @incoming_amf_object.headers.first}
|
|
24
|
+
it('should be an instance of AMFHeader') { @header.should be_an_instance_of(AMFHeader)}
|
|
25
|
+
it('should declare name "Credentials"') { @header.name.should == "Credentials"}
|
|
26
|
+
it('should declare must_understand 0') { @header.must_understand.should == 0}
|
|
27
|
+
it('should declare length 31') { @header.length.should == 31}
|
|
28
|
+
it('should declare value {:userid=>"13", :password=>"1234"}') { @header.value.should == {:userid=>"13", :password=>"1234"}}
|
|
29
|
+
end #RAMF simple_amf_example incoming_amf_object first_header
|
|
30
|
+
|
|
31
|
+
describe "first_message" do
|
|
32
|
+
before(:all) {@message = @incoming_amf_object.messages.first}
|
|
33
|
+
incoming_amf_object_message_examples(:response_uri=>"/1", :length=>23, :target_uri=>"AdminController.testMethod")
|
|
34
|
+
it('should declare value ["param1", "param2"]') { @message.value.should == ["param1", "param2"]}
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
describe "processed_incoming_amf_object" do
|
|
38
|
+
before(:all) {@processed_incoming_amf_object = @incoming_amf_object.process}
|
|
39
|
+
processed_incoming_amf_object_examples
|
|
40
|
+
|
|
41
|
+
describe "message" do
|
|
42
|
+
before(:all) {@message = @processed_incoming_amf_object.messages.first}
|
|
43
|
+
processed_incoming_amf_object_message_examples(:target_uri=>"/1/onResult")
|
|
44
|
+
it('should declare value "SimpleAMF: AdminController.test_method with credentials {:password=>\"1234\", :userid=>\"13\"}"') {
|
|
45
|
+
@message.value.should == "SimpleAMF: AdminController.test_method with credentials #{{:password=>"1234", :userid=>"13"}.inspect}"}
|
|
46
|
+
|
|
47
|
+
end #RAMF simple_amf_example incoming_amf_object processed_incoming_amf_object message
|
|
48
|
+
|
|
49
|
+
end #RAMF simple_amf_example incoming_amf_object processed_incoming_amf_object
|
|
50
|
+
|
|
51
|
+
end #RAMF simple_amf_example incoming_amf_object
|
|
52
|
+
|
|
53
|
+
end #RAMF simple_amf_example
|
|
54
|
+
|
|
55
|
+
end #RAMF
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
require File.join(File.dirname(__FILE__),'../spec_helper')
|
|
2
|
+
require File.join(File.dirname(__FILE__),'examples_helper')
|
|
3
|
+
include RAMF
|
|
4
|
+
include ExampleHelper
|
|
5
|
+
|
|
6
|
+
describe "RAMF" do
|
|
7
|
+
|
|
8
|
+
describe "simple_remoting_example" do
|
|
9
|
+
before(:all) do
|
|
10
|
+
work_with_example(:simple_remoting) do |f|
|
|
11
|
+
@deserializer = Deserializer::Base.new(f)
|
|
12
|
+
@incoming_amf_object = @deserializer.process
|
|
13
|
+
OperationProcessorsManager.add_operation_processor(ExampleHelper::OperationProcessor)
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
describe "incoming_amf_object" do
|
|
18
|
+
incoming_amf_object_examples
|
|
19
|
+
|
|
20
|
+
describe "message" do
|
|
21
|
+
before(:all) { @message = @incoming_amf_object.messages.first}
|
|
22
|
+
incoming_amf_object_message_examples(:response_uri=>"/2", :length=>237, :target_uri=>"null")
|
|
23
|
+
|
|
24
|
+
describe "value" do
|
|
25
|
+
before(:all) {@value = @message.value.first}
|
|
26
|
+
incoming_amf_object_message_value_examples(:class=>FlexObjects::RemotingMessage,
|
|
27
|
+
:headers=>{:DSEndpoint=>"ramf", :DSId=>"nil"},
|
|
28
|
+
:messageId=>"91B3B766-DE81-122D-E7FA-E18B83359EE8",
|
|
29
|
+
:body=>["3"],
|
|
30
|
+
:destination=>"HomeController",
|
|
31
|
+
:operation=>"getList")
|
|
32
|
+
it('should declare source nil') { @value.source.should == nil }
|
|
33
|
+
|
|
34
|
+
end #RAMF simple_remoting_example incoming_amf_object message value
|
|
35
|
+
|
|
36
|
+
end #RAMF simple_remoting_example incoming_amf_object message
|
|
37
|
+
|
|
38
|
+
describe "processed_incoming_amf_object" do
|
|
39
|
+
before(:all) {@processed_incoming_amf_object = @incoming_amf_object.process}
|
|
40
|
+
processed_incoming_amf_object_examples
|
|
41
|
+
|
|
42
|
+
describe "message" do
|
|
43
|
+
before(:all) {@message = @processed_incoming_amf_object.messages.first}
|
|
44
|
+
processed_incoming_amf_object_message_examples(:target_uri=>"/2/onResult")
|
|
45
|
+
|
|
46
|
+
describe "value" do
|
|
47
|
+
before(:all) {@value = @message.value}
|
|
48
|
+
processed_incoming_amf_object_message_value_examples(:body=>"RemotingMessage: HomeController.get_list without credentials",
|
|
49
|
+
:correlationId=>"91B3B766-DE81-122D-E7FA-E18B83359EE8")
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
end #RAMF simple_remoting_example incoming_amf_object processed_incoming_amf_object message
|
|
53
|
+
|
|
54
|
+
end #RAMF simple_remoting_example incoming_amf_object processed_incoming_amf_object
|
|
55
|
+
|
|
56
|
+
end #RAMF simple_remoting_example incoming_amf_object
|
|
57
|
+
|
|
58
|
+
end #RAMF simple_remoting_example
|
|
59
|
+
|
|
60
|
+
end #RAMF
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
require File.join(File.dirname(__FILE__),'../spec_helper')
|
|
2
|
+
|
|
3
|
+
class DummyClass;end;
|
|
4
|
+
describe Class do
|
|
5
|
+
|
|
6
|
+
after(:each) do
|
|
7
|
+
DummyClass.instance_variable_set('@flex_remoting',nil)
|
|
8
|
+
RAMF::FlexClassTraits::KNOWN_CLASSES.delete("DummyClass")
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
it 'should have flex_remoting marked as a transient member' do
|
|
12
|
+
DummyClass.flex_remoting.transient_members.should include(:flex_remoting)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
it 'should get a default name accurding to the class name' do
|
|
16
|
+
DummyClass.flex_remoting.name.should eql("DummyClass")
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
describe 'flex_remoting' do
|
|
20
|
+
it 'should return an instance of RAMF::FlexClassTraits' do
|
|
21
|
+
DummyClass.flex_remoting.should be_an_instance_of(RAMF::FlexClassTraits)
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
describe 'flex_remoting_transient' do
|
|
26
|
+
it 'should add transient members' do
|
|
27
|
+
DummyClass.flex_remoting_transient(:secret_attribute, :stupid_attribute)
|
|
28
|
+
DummyClass.flex_remoting.transient_members.should include(:secret_attribute)
|
|
29
|
+
DummyClass.flex_remoting.transient_members.should include(:stupid_attribute)
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
describe 'flex_alias' do
|
|
34
|
+
it 'should change the remote name of the class' do
|
|
35
|
+
DummyClass.flex_alias :ActionScriptDummyClass
|
|
36
|
+
DummyClass.flex_remoting.name.should eql("ActionScriptDummyClass")
|
|
37
|
+
RAMF::FlexClassTraits::KNOWN_CLASSES.delete("ActionScriptDummyClass")
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
describe 'flex_remoting_scope' do
|
|
42
|
+
it 'should add exceptions to scope :limited' do
|
|
43
|
+
DummyClass.flex_remoting_scope :limited, :except=>[:phone,:email]
|
|
44
|
+
DummyClass.flex_remoting.amf_scope_options[:limited][:except].should include(:phone)
|
|
45
|
+
DummyClass.flex_remoting.amf_scope_options[:limited][:except].should include(:email)
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
it 'should define members to scope :private' do
|
|
49
|
+
DummyClass.flex_remoting_scope :private, :only=>[:fullname, :nickname]
|
|
50
|
+
DummyClass.flex_remoting.amf_scope_options[:private][:only].should include(:fullname)
|
|
51
|
+
DummyClass.flex_remoting.amf_scope_options[:private][:only].should include(:nickname)
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
it 'should raise an error when both :only and :except are sent together' do
|
|
55
|
+
lambda {
|
|
56
|
+
DummyClass.flex_remoting_scope :limited, :except=>[:phone,:email], :only=>[:phone]
|
|
57
|
+
}.should raise_error(RuntimeError)
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
end
|
|
Binary file
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
describe 'deserializer1.bin' do
|
|
2
|
+
before(:all) do
|
|
3
|
+
@amf_object = deserialize_from_file('deserializer1.bin')
|
|
4
|
+
end
|
|
5
|
+
|
|
6
|
+
it 'should have the right properties' do
|
|
7
|
+
@amf_object.version.should be(0)
|
|
8
|
+
@amf_object.client.should be(3)
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
it 'should have 1 header' do
|
|
12
|
+
@amf_object.headers.size.should be(1)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
it 'should have a header with the right properties' do
|
|
16
|
+
header = @amf_object.get_header_by_key("Credentials")
|
|
17
|
+
header.value.should == {:userid=>"13", :password=>"1234"}
|
|
18
|
+
header.name.should == "Credentials"
|
|
19
|
+
header.must_understand.should be(0)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
it 'should have 1 message' do
|
|
23
|
+
@amf_object.messages.size.should be(1)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
it 'should have a message with the right properties' do
|
|
27
|
+
@amf_object.messages[0].target_uri.should eql("AdminController.testMethod")
|
|
28
|
+
@amf_object.messages[0].response_uri.should eql("/1")
|
|
29
|
+
@amf_object.messages[0].value.should eql(["param1","param2"])
|
|
30
|
+
end
|
|
31
|
+
end
|
|
Binary file
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
#class User
|
|
2
|
+
# attr_accessor :created_on, :alien, :name, :update_profile,
|
|
3
|
+
# :preferences, :referer_id, :fb_removed_on,
|
|
4
|
+
# :facebook_uid, :id, :last_visit, :facebook_session_key,
|
|
5
|
+
# :limited, :screen_name, :password, :email, :email_confirmed
|
|
6
|
+
#end
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
describe 'deserializer1.bin' do
|
|
10
|
+
before(:all) do
|
|
11
|
+
@amf_object = deserialize_from_file('deserializer2.bin')
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
it 'should have the right properties' do
|
|
15
|
+
# p @amf_object
|
|
16
|
+
# p @amf_object.messages[0].value[0]._explicitType
|
|
17
|
+
@amf_object.version.should be(0)
|
|
18
|
+
@amf_object.client.should be(3)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
it 'should have 1 header' do
|
|
22
|
+
@amf_object.headers.size.should be(1)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
it 'should have a header with the right properties' do
|
|
26
|
+
@amf_object.headers[0].value.should == {:userid=>"13", :password=>"1234"}
|
|
27
|
+
@amf_object.headers[0].name.should == "Credentials"
|
|
28
|
+
@amf_object.headers[0].must_understand.should be(0)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
it 'should have 1 message' do
|
|
32
|
+
@amf_object.messages.size.should be(1)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
it 'should have a message with the right properties' do
|
|
36
|
+
@amf_object.messages[0].target_uri.should eql("AdminController.testMethod")
|
|
37
|
+
@amf_object.messages[0].response_uri.should eql("/1")
|
|
38
|
+
@amf_object.messages[0].value.first.should be_an_instance_of(User)
|
|
39
|
+
end
|
|
40
|
+
end
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
require File.join(File.dirname(__FILE__),'spec_helper')
|
|
2
|
+
|
|
3
|
+
class DummyClass;end;
|
|
4
|
+
|
|
5
|
+
describe RAMF::FlexClassTraits do
|
|
6
|
+
|
|
7
|
+
before(:each) do
|
|
8
|
+
DummyClass.instance_variable_set('@flex_remoting',nil)
|
|
9
|
+
RAMF::FlexClassTraits::KNOWN_CLASSES.delete("DummyClass")
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
it 'sholud return the class\'s name' do
|
|
13
|
+
DummyClass.flex_remoting.name.should eql("DummyClass")
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
it 'should return the class\'s sealed members' do
|
|
17
|
+
DummyClass.flex_remoting_members :some_attribute
|
|
18
|
+
DummyClass.flex_remoting.members.should include(:some_attribute)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
it 'should raise an error when there is a duplicate ACtionScript class name' do
|
|
22
|
+
StandardError.flex_remoting
|
|
23
|
+
lambda {
|
|
24
|
+
DummyClass.flex_remoting.name = "StandardError"
|
|
25
|
+
}.should raise_error
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
it 'should give you a smalll meal and a tight seat when you are in economy' do
|
|
29
|
+
DummyClass.flex_remoting_scope :economy, :only=>[:small_meal, :tight_seat]
|
|
30
|
+
DummyClass.flex_remoting.members(:economy).should eql([:small_meal, :tight_seat])
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
it 'should be a dynamic object by default' do
|
|
34
|
+
DummyClass.flex_remoting.is_dynamic.should be(true)
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
it 'should have 1 dynamic_members_finder' do
|
|
38
|
+
DummyClass.flex_remoting.dynamic_members_finders.size.should == 1
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
it 'should iterate over all dynamic members finders' do
|
|
42
|
+
dc = DummyClass.new
|
|
43
|
+
dc.instance_variable_set('@attrib',"value")
|
|
44
|
+
DummyClass.flex_remoting.dynamic_members(dc).should == {:attrib=>"value"}
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
it 'should increase the number of dynamic members finders by 1' do
|
|
48
|
+
lambda { DummyClass.flex_dynamic_members_finder{[:fiction_attribute]}
|
|
49
|
+
}.should change(DummyClass.flex_remoting.dynamic_members_finders, :size).by(1)
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
end
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
#this file checks the behavior of FlexClassTraits with inheritance
|
|
2
|
+
require File.join(File.dirname(__FILE__),'spec_helper')
|
|
3
|
+
|
|
4
|
+
class ParentClass
|
|
5
|
+
flex_remoting_members :title, :body, :views_count
|
|
6
|
+
flex_remoting_transient :trans1, :trans2
|
|
7
|
+
flex_remoting_scope :reader, :only=>[:title, :body]
|
|
8
|
+
flex_remoting_scope :critic, :except=>[:views_count]
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class ChildClass < ParentClass
|
|
13
|
+
flex_remoting_members :updates_count
|
|
14
|
+
flex_remoting_transient :trans3, :trans4
|
|
15
|
+
flex_remoting_scope :critic, :except=>[:updates_count]
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
describe ParentClass do
|
|
19
|
+
|
|
20
|
+
it 'should have transient members :trans1 and :trans2' do
|
|
21
|
+
ParentClass.flex_remoting.transient_members.should include(:trans1)
|
|
22
|
+
ParentClass.flex_remoting.transient_members.should include(:trans2)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
it 'should only render :title and :body when in scope :reader' do
|
|
26
|
+
ParentClass.flex_remoting.amf_scope_options[:reader][:only].should == [:title, :body]
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
it 'should render everything except :views_count when in scope :critic' do
|
|
30
|
+
ParentClass.flex_remoting.amf_scope_options[:critic][:except].should == [:views_count]
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
it 'should have members :title, :body and :views_count' do
|
|
34
|
+
ParentClass.flex_remoting.members.should == [:title, :body, :views_count]
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
describe ChildClass do
|
|
39
|
+
|
|
40
|
+
it 'should have transient members :trans1, :trans2, :trans3 and :trans4' do
|
|
41
|
+
ChildClass.flex_remoting.transient_members.should include(:trans1)
|
|
42
|
+
ChildClass.flex_remoting.transient_members.should include(:trans2)
|
|
43
|
+
ChildClass.flex_remoting.transient_members.should include(:trans3)
|
|
44
|
+
ChildClass.flex_remoting.transient_members.should include(:trans4)
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
it 'should only render :title and :body when in scope :reader' do
|
|
48
|
+
ChildClass.flex_remoting.amf_scope_options[:reader][:only].should == [:title, :body]
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
it 'should render everything except :updates_count when in scope :critic' do
|
|
52
|
+
ChildClass.flex_remoting.amf_scope_options[:critic][:except].should == [:updates_count]
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
it 'should have members :title, :body, :views_count and :updates_count' do
|
|
56
|
+
ChildClass.flex_remoting.members.should == [:title, :body, :views_count, :updates_count]
|
|
57
|
+
end
|
|
58
|
+
end
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
require File.join(File.dirname(__FILE__),'../spec_helper')
|
|
2
|
+
|
|
3
|
+
describe RAMF::IO::ReferenceTable do
|
|
4
|
+
include RAMF::IO::ReferenceTableUser
|
|
5
|
+
|
|
6
|
+
before(:each) do
|
|
7
|
+
register_reference_table
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
it 'should register the reference table' do
|
|
11
|
+
@reference_table.should be_an_instance_of(RAMF::IO::ReferenceTable)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
it 'should store and retrive strings' do
|
|
15
|
+
store :string, "Some String"
|
|
16
|
+
retrive(:string, "Some String").should be(0)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
it 'should store and retrive strings in the right order' do
|
|
20
|
+
store :string, "First String"
|
|
21
|
+
store :string, "Second String"
|
|
22
|
+
retrive(:string, "First String").should be(0)
|
|
23
|
+
retrive(:string, "Second String").should be(1)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
it 'should retrive objects in the right order(with blocks)' do
|
|
27
|
+
@object1 = Object.new
|
|
28
|
+
@object2 = Object.new
|
|
29
|
+
store :object do
|
|
30
|
+
store :object do
|
|
31
|
+
@object2
|
|
32
|
+
end
|
|
33
|
+
@object1
|
|
34
|
+
end
|
|
35
|
+
retrive(:object,0).should be(@object1)
|
|
36
|
+
retrive(:object,1).should be(@object2)
|
|
37
|
+
end
|
|
38
|
+
end
|