Test BinaryProtocol#read_message_header with bad data
authorKevin Clark <kclark@apache.org>
Wed, 18 Jun 2008 01:12:48 +0000 (01:12 +0000)
committerKevin Clark <kclark@apache.org>
Wed, 18 Jun 2008 01:12:48 +0000 (01:12 +0000)
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@668978 13f79535-47bb-0310-9956-ffa450edef68

lib/rb/spec/binaryprotocol_spec.rb

index 5820fa9..96bafef 100644 (file)
@@ -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)