Skip to content

Commit ed623f6

Browse files
committed
add some more tests for various framing breakages
1 parent f9de107 commit ed623f6

File tree

1 file changed

+29
-3
lines changed

1 file changed

+29
-3
lines changed

test/src/com/rabbitmq/client/test/functional/UnexpectedFrames.java

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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\0001234567890".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

Comments
 (0)