blob: aeba1e6ab37028435da42f913a5990eb8a5f2249 [file] [log] [blame]
jcc4a20a5f2015-04-30 15:43:39 +08001package org.onosproject.net.tunnel;
2
3import static org.hamcrest.MatcherAssert.assertThat;
4import static org.hamcrest.Matchers.is;
5import static org.hamcrest.Matchers.notNullValue;
6import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
7
8import org.junit.Test;
9
10import com.google.common.testing.EqualsTester;
11
12/**
13 * Unit tests for tunnel id class.
14 */
15public 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}