summaryrefslogtreecommitdiff
path: root/directory/src/test/java/com
diff options
context:
space:
mode:
Diffstat (limited to 'directory/src/test/java/com')
-rw-r--r--directory/src/test/java/com/orbekk/same/discovery/NetworkEntryTest.java27
1 files changed, 27 insertions, 0 deletions
diff --git a/directory/src/test/java/com/orbekk/same/discovery/NetworkEntryTest.java b/directory/src/test/java/com/orbekk/same/discovery/NetworkEntryTest.java
new file mode 100644
index 0000000..455de90
--- /dev/null
+++ b/directory/src/test/java/com/orbekk/same/discovery/NetworkEntryTest.java
@@ -0,0 +1,27 @@
+package com.orbekk.same.discovery;
+
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+
+import com.orbekk.same.directory.NetworkEntry;
+
+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));
+ }
+}