@@ -133,16 +133,42 @@ public Frame confuse(Frame frame) {
133
133
});
134
134
}
135
135
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
+ }
138
158
159
+ private void expectError (int error , Confuser confuser ) throws IOException {
139
160
((ConfusedFrameHandler )((AMQConnection )connection ).getFrameHandler ()).
140
161
confuser = confuser ;
141
162
142
163
//NB: the frame confuser relies on the encoding of the
143
164
//method field to be at least 8 bytes long
144
165
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 );
146
172
}
147
173
148
174
}
0 commit comments