blob: 87421dbf40c458449cb85028784f1e183aeb0cb6 [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 name class.
14 */
15public class TunnelNameTest {
16 final TunnelName name1 = TunnelName.tunnelName("name1");
17 final TunnelName sameAsName1 = TunnelName.tunnelName("name1");
18 final TunnelName name2 = TunnelName.tunnelName("name2");
19
20 /**
21 * Checks that the TunnelName class is immutable.
22 */
23 @Test
24 public void testImmutability() {
25 assertThatClassIsImmutable(TunnelName.class);
26 }
27
28 /**
29 * Checks the operation of equals(), hashCode() and toString() methods.
30 */
31 @Test
32 public void testEquals() {
33 new EqualsTester().addEqualityGroup(name1, sameAsName1)
34 .addEqualityGroup(name2).testEquals();
35 }
36
37 /**
38 * Checks the construction of a OpenFlowGroupId object.
39 */
40 @Test
41 public void testConstruction() {
42 final String nameValue = "name3";
43 final TunnelName name = TunnelName.tunnelName(nameValue);
44 assertThat(name, is(notNullValue()));
45 assertThat(name.value(), is(nameValue));
46 }
47
48}