jcc | 4a20a5f | 2015-04-30 15:43:39 +0800 | [diff] [blame^] | 1 | package org.onosproject.net.tunnel; |
| 2 | |
| 3 | import static org.hamcrest.MatcherAssert.assertThat; |
| 4 | import static org.hamcrest.Matchers.is; |
| 5 | import static org.hamcrest.Matchers.notNullValue; |
| 6 | import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable; |
| 7 | |
| 8 | import org.junit.Test; |
| 9 | |
| 10 | import com.google.common.testing.EqualsTester; |
| 11 | |
| 12 | /** |
| 13 | * Unit tests for tunnel id class. |
| 14 | */ |
| 15 | public class TunnelIdTest { |
| 16 | |
| 17 | final TunnelId tunnelId1 = TunnelId.valueOf(1); |
| 18 | final TunnelId sameAstunnelId1 = TunnelId.valueOf(1); |
| 19 | final TunnelId tunnelId2 = TunnelId.valueOf(2); |
| 20 | |
| 21 | /** |
| 22 | * Checks that the TunnelId class is immutable. |
| 23 | */ |
| 24 | @Test |
| 25 | public void testImmutability() { |
| 26 | assertThatClassIsImmutable(TunnelId.class); |
| 27 | } |
| 28 | |
| 29 | /** |
| 30 | * Checks the operation of equals(), hashCode() and toString() methods. |
| 31 | */ |
| 32 | @Test |
| 33 | public void testEquals() { |
| 34 | new EqualsTester() |
| 35 | .addEqualityGroup(tunnelId1, sameAstunnelId1) |
| 36 | .addEqualityGroup(tunnelId2) |
| 37 | .testEquals(); |
| 38 | } |
| 39 | |
| 40 | /** |
| 41 | * Checks the construction of a FlowId object. |
| 42 | */ |
| 43 | @Test |
| 44 | public void testConstruction() { |
| 45 | final long tunnelIdValue = 7777L; |
| 46 | final TunnelId tunnelId = TunnelId.valueOf(tunnelIdValue); |
| 47 | assertThat(tunnelId, is(notNullValue())); |
| 48 | assertThat(tunnelId.id(), is(tunnelIdValue)); |
| 49 | } |
| 50 | } |