From: Kevin Clark Date: Wed, 18 Jun 2008 01:12:48 +0000 (+0000) Subject: Test BinaryProtocol#read_message_header with bad data X-Git-Tag: 0.2.0~572 X-Git-Url: https://source.supwisdom.com/gerrit/gitweb?a=commitdiff_plain;h=c13c33bfad64404d8e064a0f6c48eaa151a87c79;p=common%2Fthrift.git Test BinaryProtocol#read_message_header with bad data git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@668978 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/lib/rb/spec/binaryprotocol_spec.rb b/lib/rb/spec/binaryprotocol_spec.rb index 5820fa95..96bafefb 100644 --- a/lib/rb/spec/binaryprotocol_spec.rb +++ b/lib/rb/spec/binaryprotocol_spec.rb @@ -175,7 +175,12 @@ class ThriftBinaryProtocolSpec < Spec::ExampleGroup @prot.read_message_begin.should == ['testMessage', MessageTypes::REPLY, 42] end - # message header is a noop + it "should raise an exception if the message header has the wrong version" do + @prot.should_receive(:read_i32).and_return(42) + lambda { @prot.read_message_begin }.should raise_error(ProtocolException, 'Missing version identifier') { |e| e.type == ProtocolException::BAD_VERSION } + end + + # message footer is a noop it "should read a field header" do @prot.should_receive(:read_byte).ordered.and_return(Types::STRING)