From 6eb5d4e440a60a5a358cf15211c5207bc590a160 Mon Sep 17 00:00:00 2001 From: hristoterezov Date: Tue, 23 Jul 2013 11:30:43 +0300 Subject: [PATCH] Tries to fix randomly failing tests. --- .../msghistory/TestMsgHistoryService.java | 52 ++++++++++--------- 1 file changed, 28 insertions(+), 24 deletions(-) diff --git a/test/net/java/sip/communicator/slick/msghistory/TestMsgHistoryService.java b/test/net/java/sip/communicator/slick/msghistory/TestMsgHistoryService.java index 11c0ba5a7..53129cd45 100644 --- a/test/net/java/sip/communicator/slick/msghistory/TestMsgHistoryService.java +++ b/test/net/java/sip/communicator/slick/msghistory/TestMsgHistoryService.java @@ -69,6 +69,8 @@ public class TestMsgHistoryService private static Date controlDate1 = null; private static Date controlDate2 = null; + + private static Object lock = new Object(); public TestMsgHistoryService(String name) { @@ -392,6 +394,21 @@ public void readRecords() msgs.contains(messagesToSend[2].getContent())); } + private static void waitWrite(long timeout) + { + synchronized (lock) + { + // wait a moment + try + { + lock.wait(timeout); + } + catch (InterruptedException ex) + { + } + } + } + public void writeRecordsToMultiChat() { try @@ -407,39 +424,26 @@ public void writeRecordsToMultiChat() TestMsgHistoryService.controlDate1 = new Date(); - Object lock = new Object(); - synchronized (lock) - { - // wait a moment - try - { - lock.wait(200); - } - catch (InterruptedException ex) - { - } - } + waitWrite(200); + room.sendMessage(messagesToSend[1]); + waitWrite(200); + room.sendMessage(messagesToSend[2]); TestMsgHistoryService.controlDate2 = new Date(); - synchronized (lock) - { - // wait a moment - try - { - lock.wait(200); - } - catch (InterruptedException ex) - { - } - } + + waitWrite(200); room.sendMessage(messagesToSend[3]); - + + waitWrite(200); + room.sendMessage(messagesToSend[4]); + + waitWrite(200); } catch(OperationFailedException ex) {