From c13c33bfad64404d8e064a0f6c48eaa151a87c79 Mon Sep 17 00:00:00 2001 From: Kevin Clark Date: Wed, 18 Jun 2008 01:12:48 +0000 Subject: [PATCH] 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 --- lib/rb/spec/binaryprotocol_spec.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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) -- 2.17.1