diff options
Diffstat (limited to 'discovery/src/test')
-rw-r--r-- | discovery/src/test/java/com/orbekk/same/discovery/NetworkEntryTest.java | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/discovery/src/test/java/com/orbekk/same/discovery/NetworkEntryTest.java b/discovery/src/test/java/com/orbekk/same/discovery/NetworkEntryTest.java new file mode 100644 index 0000000..dacaf9c --- /dev/null +++ b/discovery/src/test/java/com/orbekk/same/discovery/NetworkEntryTest.java @@ -0,0 +1,25 @@ +package com.orbekk.same.discovery; + +import static org.junit.Assert.*; + +import org.junit.Test; + +public class NetworkEntryTest { + @Test + public void testExpiry() { + NetworkEntry entry = new NetworkEntry("NetworkA", "UrlA"); + entry.register(100); + assertFalse(entry.hasExpired(50)); + assertTrue(entry.hasExpired(101)); + } + + @Test + public void testRegister() { + NetworkEntry entry = new NetworkEntry("NetworkB", "UrlB"); + long time = 1000000000000l; + entry.register(time); + assertTrue(entry.hasExpired(time+1)); + entry.register(time + 1000); + assertFalse(entry.hasExpired(time + 500)); + } +} |