readLength counter not reset after reading the content of the first BytesMessage.

Added new test that sends multiple BytesMessages to cover this case.

git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@990827 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Timothy A. Bish 2010-08-30 15:47:16 +00:00
parent f3c81eebb9
commit f8a601a85b
2 changed files with 53 additions and 20 deletions

View File

@ -156,6 +156,7 @@ public class StompNIOTransport extends TcpTransport {
// read desired content length
if (readLength++ == contentLength) {
processCommand();
readLength = 0;
} else {
currentCommand.write(b);
}

View File

@ -424,6 +424,38 @@ public class StompTest extends CombinationTestSupport {
stompConnection.sendFrame(frame);
}
public void testSendMultipleBytesMessages() throws Exception {
final int MSG_COUNT = 50;
String frame = "CONNECT\n" + "login: system\n" + "passcode: manager\n\n" + Stomp.NULL;
stompConnection.sendFrame(frame);
frame = stompConnection.receiveFrame();
assertTrue(frame.startsWith("CONNECTED"));
for( int ix = 0; ix < MSG_COUNT; ix++) {
frame = "SEND\n destination:/queue/" + getQueueName() + "\ncontent-length:5" + " \n\n" + "\u0001\u0002\u0000\u0004\u0005" + Stomp.NULL;
stompConnection.sendFrame(frame);
}
frame = "SUBSCRIBE\n" + "destination:/queue/" + getQueueName() + "\n" + "ack:auto\n\n" + Stomp.NULL;
stompConnection.sendFrame(frame);
for( int ix = 0; ix < MSG_COUNT; ix++) {
StompFrame message = stompConnection.receive();
assertTrue(message.getAction().startsWith("MESSAGE"));
String length = message.getHeaders().get("content-length");
assertEquals("5", length);
assertEquals(5, message.getContent().length);
}
frame = "DISCONNECT\n" + "\n\n" + Stomp.NULL;
stompConnection.sendFrame(frame);
}
public void testSubscribeWithMessageSentWithProperties() throws Exception {
String frame = "CONNECT\n" + "login: system\n" + "passcode: manager\n\n" + Stomp.NULL;