diff options
author | Keuin <[email protected]> | 2022-08-13 23:21:48 +0800 |
---|---|---|
committer | Keuin <[email protected]> | 2022-08-13 23:21:48 +0800 |
commit | b721f1eb0f2460bfb7524d8067bddc7905d64876 (patch) | |
tree | f99ca1a4be062c1b5ec182fdb3c31f5241427a6c /src/test | |
parent | b068d11b1d8423ae07b7deaf4cdb57b47b828b26 (diff) |
Add HistoricMessageRecorder.
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/java/com/keuin/crosslink/messaging/history/HistoricMessageRecorderTest.java | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/test/java/com/keuin/crosslink/messaging/history/HistoricMessageRecorderTest.java b/src/test/java/com/keuin/crosslink/messaging/history/HistoricMessageRecorderTest.java new file mode 100644 index 0000000..4dfdfd4 --- /dev/null +++ b/src/test/java/com/keuin/crosslink/messaging/history/HistoricMessageRecorderTest.java @@ -0,0 +1,31 @@ +package com.keuin.crosslink.messaging.history; + +import com.keuin.crosslink.messaging.endpoint.IEndpoint; +import com.keuin.crosslink.messaging.message.IMessage; +import com.keuin.crosslink.messaging.sender.ISender; +import com.keuin.crosslink.testable.FakeEndpoint; +import org.junit.jupiter.api.Test; + +import java.util.ArrayList; +import java.util.UUID; + +import static org.junit.jupiter.api.Assertions.*; + +class HistoricMessageRecorderTest { + + @Test + void testTTL() throws InterruptedException { + var recorder = new HistoricMessageRecorder(1000); + var ep0 = new FakeEndpoint("z"); + var sender = ISender.create("sender", UUID.randomUUID()); + var msg = IMessage.create(ep0, sender, "MSG,,,"); + recorder.addMessage(msg); + Thread.sleep(500); + var list = recorder.getMessages(); + assertEquals(1, list.size()); + assertEquals(msg, list.get(0)); + Thread.sleep(510); + list = recorder.getMessages(); + assertEquals(0, list.size()); + } +}
\ No newline at end of file |