@@ -133,16 +133,42 @@ public Frame confuse(Frame frame) {
133133 });
134134 }
135135
136- private void expectUnexpectedFrameError (Confuser confuser )
137- throws IOException {
136+ public void testHeartbeatOnChannel () throws IOException {
137+ expectUnexpectedFrameError (new Confuser () {
138+ public Frame confuse (Frame frame ) {
139+ if (frame .type == AMQP .FRAME_METHOD ) {
140+ return new Frame (AMQP .FRAME_HEARTBEAT , frame .channel );
141+ }
142+ return frame ;
143+ }
144+ });
145+ }
146+
147+ public void testUnknownFrameType () throws IOException {
148+ expectError (AMQP .FRAME_ERROR , new Confuser () {
149+ public Frame confuse (Frame frame ) {
150+ if (frame .type == AMQP .FRAME_METHOD ) {
151+ return new Frame (0 , frame .channel ,
152+ "1234567890\000 1234567890" .getBytes ());
153+ }
154+ return frame ;
155+ }
156+ });
157+ }
138158
159+ private void expectError (int error , Confuser confuser ) throws IOException {
139160 ((ConfusedFrameHandler )((AMQConnection )connection ).getFrameHandler ()).
140161 confuser = confuser ;
141162
142163 //NB: the frame confuser relies on the encoding of the
143164 //method field to be at least 8 bytes long
144165 channel .basicPublish ("" , "routing key" , null , "Hello" .getBytes ());
145- expectError (AMQP .UNEXPECTED_FRAME );
166+ expectError (error );
167+ }
168+
169+ private void expectUnexpectedFrameError (Confuser confuser )
170+ throws IOException {
171+ expectError (AMQP .UNEXPECTED_FRAME , confuser );
146172 }
147173
148174}
0 commit comments