aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorDamian Minkov <damencho@jitsi.org>2014-03-13 12:04:51 +0200
committerDamian Minkov <damencho@jitsi.org>2014-03-13 18:09:09 +0200
commit5974d1b7b9ed013c0e917be7974f380599d0cb34 (patch)
tree781ae951f695b20a5a8dd3790bdea1379d10db80 /test
parentcb468c1429287b9267b41b092fa583e5adf4697d (diff)
downloadjitsi-5974d1b7b9ed013c0e917be7974f380599d0cb34.zip
jitsi-5974d1b7b9ed013c0e917be7974f380599d0cb34.tar.gz
jitsi-5974d1b7b9ed013c0e917be7974f380599d0cb34.tar.bz2
Adds option to limit the number of history records stored, FIFO. Updates timestamp of records on record update.
Diffstat (limited to 'test')
-rw-r--r--test/net/java/sip/communicator/slick/history/TestHistoryService.java62
1 files changed, 62 insertions, 0 deletions
diff --git a/test/net/java/sip/communicator/slick/history/TestHistoryService.java b/test/net/java/sip/communicator/slick/history/TestHistoryService.java
index 93fda1d..74ad5fb 100644
--- a/test/net/java/sip/communicator/slick/history/TestHistoryService.java
+++ b/test/net/java/sip/communicator/slick/history/TestHistoryService.java
@@ -44,6 +44,7 @@ public class TestHistoryService extends TestCase {
suite.addTest(new TestHistoryService("testReadRecords"));
suite.addTest(new TestHistoryService("testPurgeLocallyStoredHistory"));
suite.addTest(new TestHistoryService("testCreatingHistoryIDFromFS"));
+ suite.addTest(new TestHistoryService("testWriteRecordsWithMaxNumber"));
return suite;
}
@@ -227,4 +228,65 @@ public class TestHistoryService extends TestCase {
testNoSpecialCharsIDFSRead.getID()[i]);
}
}
+
+ public void testWriteRecordsWithMaxNumber()
+ {
+ HistoryWriter writer = this.history.getWriter();
+ HistoryReader reader = this.history.getReader();
+
+ try
+ {
+
+ for (int i = 0; i < 20; i++)
+ {
+ writer.addRecord(new String[] { "" + i,
+ "name" + i,
+ i % 2 == 0 ? "m" : "f" }, 20);
+ synchronized(this)
+ {
+ try
+ {
+ wait(100);
+ }
+ catch(Throwable t){}
+ }
+ }
+
+ QueryResultSet<HistoryRecord> recs = reader.findLast(20);
+ int count = 0;
+ while(recs.hasNext())
+ {
+ count++;
+ recs.next();
+ }
+
+ assertEquals( "Wrong count of messages", 20, count);
+
+ writer.addRecord(new String[] { "" + 21,
+ "name" + 21, "f" }, 20);
+
+ recs = reader.findLast(20);
+ count = 0;
+ boolean foundFirstMessage = false;
+ while(recs.hasNext())
+ {
+ count++;
+ HistoryRecord hr = recs.next();
+
+ if(hr.getPropertyValues()[0].equals("0"))
+ foundFirstMessage = true;
+ }
+
+ assertEquals( "Wrong count of messages", 20, count);
+
+ assertFalse("Wrong message removed, must be the first one",
+ foundFirstMessage);
+
+ } catch (Exception e)
+ {
+ e.printStackTrace();
+ fail("Could not write records. Reason: " + e);
+ }
+ }
+
}