Trying to get this to pass more reliably on linux

git-svn-id: https://svn.apache.org/repos/asf/incubator/activemq/trunk@418424 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Hiram R. Chirino 2006-07-01 00:32:26 +00:00
parent 0da70121d4
commit 47abda2a7d
1 changed files with 15 additions and 18 deletions

View File

@ -77,11 +77,11 @@ public class StompSubscriptionRemoveTest extends TestCase {
stompSocket = new Socket("localhost", 61613); stompSocket = new Socket("localhost", 61613);
inputBuffer = new ByteArrayOutputStream(); inputBuffer = new ByteArrayOutputStream();
String connect_frame = "CONNECT\n" + "login: brianm\n" + "passcode: wombats\n" + "\n" + Stomp.NULL; String connect_frame = "CONNECT\n" + "login: brianm\n" + "passcode: wombats\n" + "\n";
sendFrame(connect_frame); sendFrame(connect_frame);
String f = receiveFrame(100000); String f = receiveFrame(100000);
String frame = "SUBSCRIBE\n" + "destination:/queue/" + getDestinationName() + "\n" + "ack:client\n\n" + Stomp.NULL; String frame = "SUBSCRIBE\n" + "destination:/queue/" + getDestinationName() + "\n" + "ack:client\n\n";
sendFrame(frame); sendFrame(frame);
int messagesCount = 0; int messagesCount = 0;
int count = 0; int count = 0;
@ -107,7 +107,7 @@ public class StompSubscriptionRemoveTest extends TestCase {
} }
String messageId = line.substring(line.indexOf(':') + 1); String messageId = line.substring(line.indexOf(':') + 1);
messageId = messageId.trim(); messageId = messageId.trim();
String ackmessage = "ACK\n" + "message-id:" + messageId + "\n\n" + Stomp.NULL; String ackmessage = "ACK\n" + "message-id:" + messageId + "\n\n";
sendFrame(ackmessage); sendFrame(ackmessage);
log.debug(receiveFrame); log.debug(receiveFrame);
//Thread.sleep(1000); //Thread.sleep(1000);
@ -115,25 +115,20 @@ public class StompSubscriptionRemoveTest extends TestCase {
++count; ++count;
} }
stompSocket.close(); stompSocket.close();
Thread.sleep(10000);
// for (int idx = 0; idx < 500; ++idx) {
// producer.send(message);
// log.debug("Sending: " +idx);
// }
stompSocket = new Socket("localhost", 61613); stompSocket = new Socket("localhost", 61613);
inputBuffer = new ByteArrayOutputStream(); inputBuffer = new ByteArrayOutputStream();
connect_frame = "CONNECT\n" + "login: brianm\n" + "passcode: wombats\n" + "\n" + Stomp.NULL; connect_frame = "CONNECT\n" + "login: brianm\n" + "passcode: wombats\n" + "\n";
sendFrame(connect_frame); sendFrame(connect_frame);
f = receiveFrame(100000); f = receiveFrame(5000);
frame = "SUBSCRIBE\n" + "destination:/queue/" + getDestinationName() + "\n" + "ack:client\n\n" + Stomp.NULL;
frame = "SUBSCRIBE\n" + "destination:/queue/" + getDestinationName() + "\n" + "ack:client\n\n";
sendFrame(frame); sendFrame(frame);
try { try {
while (count != 2000) { while (count != 2000) {
String receiveFrame = receiveFrame(10000); String receiveFrame = receiveFrame(5000);
DataInput input = new DataInputStream(new ByteArrayInputStream(receiveFrame.getBytes())); DataInput input = new DataInputStream(new ByteArrayInputStream(receiveFrame.getBytes()));
String line; String line;
while (true) { while (true) {
@ -148,13 +143,14 @@ public class StompSubscriptionRemoveTest extends TestCase {
} }
} }
} }
line = input.readLine(); line = input.readLine();
if (line == null) { if (line == null) {
throw new IOException("connection was closed"); throw new IOException("connection was closed");
} }
String messageId = line.substring(line.indexOf(':') + 1); String messageId = line.substring(line.indexOf(':') + 1);
messageId = messageId.trim(); messageId = messageId.trim();
String ackmessage = "ACK\n" + "message-id:" + messageId + "\n\n" + Stomp.NULL; String ackmessage = "ACK\n" + "message-id:" + messageId + "\n\n";
sendFrame(ackmessage); sendFrame(ackmessage);
log.debug("Received: " + receiveFrame); log.debug("Received: " + receiveFrame);
//Thread.sleep(1000); //Thread.sleep(1000);
@ -164,10 +160,12 @@ public class StompSubscriptionRemoveTest extends TestCase {
} }
catch (IOException ex) { catch (IOException ex) {
// timeout ex.printStackTrace();
} }
stompSocket.close(); stompSocket.close();
broker.stop(); broker.stop();
log.info("Total messages received: " + messagesCount); log.info("Total messages received: " + messagesCount);
assertTrue("Messages received after connection loss: " + messagesCount, messagesCount >= 2000); assertTrue("Messages received after connection loss: " + messagesCount, messagesCount >= 2000);
@ -181,9 +179,8 @@ public class StompSubscriptionRemoveTest extends TestCase {
public void sendFrame(String data) throws Exception { public void sendFrame(String data) throws Exception {
byte[] bytes = data.getBytes("UTF-8"); byte[] bytes = data.getBytes("UTF-8");
OutputStream outputStream = stompSocket.getOutputStream(); OutputStream outputStream = stompSocket.getOutputStream();
for (int i = 0; i < bytes.length; i++) { outputStream.write(bytes);
outputStream.write(bytes[i]); outputStream.write(0);
}
outputStream.flush(); outputStream.flush();
} }