@@ -12,6 +12,7 @@ public class ChunkCacheTests {
1212 private static final String MESSAGE_TWO = "message two" ;
1313 private static final String MESSAGE_THREE = "message three" ;
1414 private static final String MESSAGE_FOUR = "message four" ;
15+ private static final String MESSAGE_FIVE = "message five" ;
1516
1617 @ Test
1718 public void chunkTest1 () throws IOException , AASPException {
@@ -30,21 +31,22 @@ public void chunkTest1() throws IOException, AASPException {
3031 AASPChunk chunk = chunkStorage .getChunk (TEST_URI , era );
3132
3233 chunk .add (MESSAGE_ONE );
33- storage .newEra ();
34+ storage .newEra (); // finish chunk one
3435 int newEra = storage .getEra ();
3536
37+ // start chunk two
3638 Assert .assertEquals (AASPEngine .nextEra (era ), newEra );
3739 chunk = chunkStorage .getChunk (TEST_URI , newEra );
3840 chunk .add (MESSAGE_TWO );
3941
40- Assert .assertEquals (AASPEngine .nextEra (era ), newEra );
41- chunk = chunkStorage .getChunk (TEST_URI , newEra );
4242 chunk .add (MESSAGE_THREE );
43- chunk = chunkStorage . getChunk ( TEST_URI , newEra );
43+
4444 chunk .add (MESSAGE_FOUR );
4545
4646 AASPChunkCache aaspChunkCache = chunkStorage .getAASPChunkCache (TEST_URI , era , newEra );
4747
48+ // add message after getting cache
49+
4850 // position test - chronological order
4951 CharSequence message = aaspChunkCache .getMessage (0 , true );
5052 Assert .assertTrue (message .toString ().equalsIgnoreCase (MESSAGE_ONE ));
@@ -59,6 +61,12 @@ public void chunkTest1() throws IOException, AASPException {
5961 message = aaspChunkCache .getMessage (1 , false );
6062 Assert .assertTrue (message .toString ().equalsIgnoreCase (MESSAGE_THREE ));
6163
64+ chunk .add (MESSAGE_FIVE );
65+
66+ aaspChunkCache .sync ();
67+ message = aaspChunkCache .getMessage (4 , true );
68+ Assert .assertTrue (message .toString ().equalsIgnoreCase (MESSAGE_FIVE ));
69+
6270 Iterator <CharSequence > messages = aaspChunkCache .getMessages ();
6371
6472 // Iterator test
@@ -71,6 +79,8 @@ public void chunkTest1() throws IOException, AASPException {
7179 Assert .assertTrue (message .toString ().equalsIgnoreCase (MESSAGE_THREE ));
7280 message = messages .next ();
7381 Assert .assertTrue (message .toString ().equalsIgnoreCase (MESSAGE_FOUR ));
82+ message = messages .next ();
83+ Assert .assertTrue (message .toString ().equalsIgnoreCase (MESSAGE_FIVE ));
7484
7585 Assert .assertFalse (messages .hasNext ());
7686
0 commit comments