summaryrefslogtreecommitdiff
path: root/lib/rb/spec
diff options
context:
space:
mode:
authorBryan Duxbury <bryanduxbury@apache.org>2009-04-01 20:10:15 +0000
committerBryan Duxbury <bryanduxbury@apache.org>2009-04-01 20:10:15 +0000
commit5b8b4845488b07007a311a0702107d6d8abe0052 (patch)
tree837129cbda8c93c270d6a6e33555fec805a07adf /lib/rb/spec
parent16b29a989e9af77130b626c011c56f07d197b8b5 (diff)
downloadthrift-5b8b4845488b07007a311a0702107d6d8abe0052.tar.gz
THRIFT-417. rb: BufferedTransport can enter an infinite loop
Switch native proto implementations to use read_all instead of read. Add a bunch of tests to verify. Also: - removed some commented code in binary_protocol_accelerated.c - struct.c was missing one of the possible native method calls - updates gem manifest (included files that didn't exist) - fixed svn:ignores of test/rb/gen-rb and lib/java/gen-java git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@761037 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'lib/rb/spec')
-rw-r--r--lib/rb/spec/binaryprotocol_spec_shared.rb73
-rw-r--r--lib/rb/spec/spec_helper.rb2
2 files changed, 75 insertions, 0 deletions
diff --git a/lib/rb/spec/binaryprotocol_spec_shared.rb b/lib/rb/spec/binaryprotocol_spec_shared.rb
index 90371b35f..18ea8e8d0 100644
--- a/lib/rb/spec/binaryprotocol_spec_shared.rb
+++ b/lib/rb/spec/binaryprotocol_spec_shared.rb
@@ -299,4 +299,77 @@ shared_examples_for 'a binary protocol' do
@trans.write([str.size].pack("N") + str)
@prot.read_string.should == str
end
+
+ it "should perform a complete rpc with no args or return" do
+ srv_test(
+ proc {|client| client.send_voidMethod()},
+ proc {|client| client.recv_voidMethod.should == nil}
+ )
+ end
+
+ it "should perform a complete rpc with a primitive return type" do
+ srv_test(
+ proc {|client| client.send_primitiveMethod()},
+ proc {|client| client.recv_primitiveMethod.should == 1}
+ )
+ end
+
+ it "should perform a complete rpc with a struct return type" do
+ srv_test(
+ proc {|client| client.send_structMethod()},
+ proc {|client|
+ result = client.recv_structMethod
+ result.set_byte_map = nil
+ result.map_byte_map = nil
+ result.should == Fixtures::COMPACT_PROTOCOL_TEST_STRUCT
+ }
+ )
+ end
+
+ def get_socket_connection
+ server = Thrift::ServerSocket.new("localhost", 9090)
+ server.listen
+
+ clientside = Thrift::Socket.new("localhost", 9090)
+ clientside.open
+ serverside = server.accept
+ [clientside, serverside, server]
+ end
+
+ def srv_test(firstblock, secondblock)
+ clientside, serverside, server = get_socket_connection
+
+ clientproto = protocol_class.new(clientside)
+ serverproto = protocol_class.new(serverside)
+
+ processor = Srv::Processor.new(SrvHandler.new)
+
+ client = Srv::Client.new(clientproto, clientproto)
+
+ # first block
+ firstblock.call(client)
+
+ processor.process(serverproto, serverproto)
+
+ # second block
+ secondblock.call(client)
+ ensure
+ clientside.close
+ serverside.close
+ server.close
+ end
+
+ class SrvHandler
+ def voidMethod()
+ end
+
+ def primitiveMethod
+ 1
+ end
+
+ def structMethod
+ Fixtures::COMPACT_PROTOCOL_TEST_STRUCT
+ end
+ end
+
end
diff --git a/lib/rb/spec/spec_helper.rb b/lib/rb/spec/spec_helper.rb
index 19db02a5f..d0994914b 100644
--- a/lib/rb/spec/spec_helper.rb
+++ b/lib/rb/spec/spec_helper.rb
@@ -48,4 +48,6 @@ require File.dirname(__FILE__) + "/../debug_proto_test/gen-rb/Srv"
module Fixtures
COMPACT_PROTOCOL_TEST_STRUCT = CompactProtoTestStruct.new(:a_binary => [0,1,2,3,4,5,6,7,8].pack('c*'))
+ COMPACT_PROTOCOL_TEST_STRUCT.set_byte_map = nil
+ COMPACT_PROTOCOL_TEST_STRUCT.map_byte_map = nil
end \ No newline at end of file