Sho SHIMIZU | cdc5013 | 2014-07-22 09:21:01 -0700 | [diff] [blame^] | 1 | package net.onrc.onos.core.newintent; |
| 2 | |
| 3 | import net.onrc.onos.api.intent.IntentId; |
| 4 | import net.onrc.onos.core.matchaction.match.PacketMatch; |
| 5 | import net.onrc.onos.core.util.SwitchPort; |
| 6 | import org.junit.Test; |
| 7 | |
| 8 | import java.util.concurrent.TimeUnit; |
| 9 | |
| 10 | import static org.hamcrest.Matchers.is; |
| 11 | import static org.junit.Assert.assertThat; |
| 12 | |
| 13 | public class PointToPointIntentTest { |
| 14 | private final IntentId id = new IntentId(0); |
| 15 | private final SwitchPort port1 = new SwitchPort(0L, 0L); |
| 16 | private final SwitchPort port2 = new SwitchPort(1L, 1L); |
| 17 | private final PacketMatch match = new PacketMatch(); |
| 18 | |
| 19 | @Test |
| 20 | public void testEqualityWhenIdleTimeoutIsZero() { |
| 21 | PointToPointIntent intent1 = new PointToPointIntent(id, port1, port2, match, |
| 22 | 0, TimeUnit.DAYS); |
| 23 | PointToPointIntent intent2 = new PointToPointIntent(id, port1, port2, match, |
| 24 | 0, TimeUnit.SECONDS); |
| 25 | |
| 26 | assertThat(intent1, is(intent2)); |
| 27 | } |
| 28 | |
| 29 | @Test |
| 30 | public void testEqualityWhenIdleTimeoutIsOneSecond() { |
| 31 | PointToPointIntent intent1 = new PointToPointIntent(id, port1, port2, match, |
| 32 | 1, TimeUnit.SECONDS); |
| 33 | PointToPointIntent intent2 = new PointToPointIntent(id, port1, port2, match, |
| 34 | 1000, TimeUnit.MILLISECONDS); |
| 35 | |
| 36 | assertThat(intent1, is(intent2)); |
| 37 | } |
| 38 | |
| 39 | @Test |
| 40 | public void testEqualityWhenIdleTimeoutIsTruncated() { |
| 41 | PointToPointIntent intent1 = new PointToPointIntent(id, port1, port2, match, |
| 42 | 1, TimeUnit.MICROSECONDS); |
| 43 | PointToPointIntent intent2 = new PointToPointIntent(id, port1, port2, match, |
| 44 | 1001, TimeUnit.NANOSECONDS); |
| 45 | |
| 46 | assertThat(intent1, is(intent2)); |
| 47 | } |
| 48 | } |