tom | b36046e | 2014-08-27 00:22:24 -0700 | [diff] [blame^] | 1 | package org.onlab.onos.event; |
| 2 | |
| 3 | import org.junit.Test; |
| 4 | |
| 5 | import static org.junit.Assert.assertEquals; |
| 6 | import static org.junit.Assert.assertTrue; |
| 7 | import static org.onlab.onos.event.TestEvent.Type.FOO; |
| 8 | |
| 9 | /** |
| 10 | * Tests of the base event abstraction. |
| 11 | */ |
| 12 | public class AbstractEventTest { |
| 13 | |
| 14 | @Test |
| 15 | public void withTime() { |
| 16 | TestEvent event = new TestEvent(FOO, "foo", 123L); |
| 17 | assertEquals("incorrect type", FOO, event.type()); |
| 18 | assertEquals("incorrect subject", "foo", event.subject()); |
| 19 | assertEquals("incorrect time", 123L, event.time()); |
| 20 | } |
| 21 | |
| 22 | @Test |
| 23 | public void withoutTime() { |
| 24 | long before = System.currentTimeMillis(); |
| 25 | TestEvent event = new TestEvent(FOO, "foo"); |
| 26 | long after = System.currentTimeMillis(); |
| 27 | assertEquals("incorrect type", FOO, event.type()); |
| 28 | assertEquals("incorrect subject", "foo", event.subject()); |
| 29 | assertTrue("incorrect time", before <= event.time() && event.time() <= after); |
| 30 | } |
| 31 | } |