blob: d0fc49c7dcc865e7884047e4d1f49f198a0d98d6 [file] [log] [blame]
Thomas Vachuskabf916ea2015-05-20 18:24:34 -07001/*
2 * Copyright 2015 Open Networking Laboratory
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package org.onosproject.incubator.net.tunnel;
jcc4a20a5f2015-04-30 15:43:39 +080018
19import static org.hamcrest.MatcherAssert.assertThat;
20import static org.hamcrest.Matchers.is;
21import static org.hamcrest.Matchers.notNullValue;
22import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
23
24import org.junit.Test;
25
26import com.google.common.testing.EqualsTester;
27
28/**
29 * Unit tests for tunnel name class.
30 */
31public class TunnelNameTest {
32 final TunnelName name1 = TunnelName.tunnelName("name1");
33 final TunnelName sameAsName1 = TunnelName.tunnelName("name1");
34 final TunnelName name2 = TunnelName.tunnelName("name2");
35
36 /**
37 * Checks that the TunnelName class is immutable.
38 */
39 @Test
40 public void testImmutability() {
41 assertThatClassIsImmutable(TunnelName.class);
42 }
43
44 /**
45 * Checks the operation of equals(), hashCode() and toString() methods.
46 */
47 @Test
48 public void testEquals() {
49 new EqualsTester().addEqualityGroup(name1, sameAsName1)
50 .addEqualityGroup(name2).testEquals();
51 }
52
53 /**
54 * Checks the construction of a OpenFlowGroupId object.
55 */
56 @Test
57 public void testConstruction() {
58 final String nameValue = "name3";
59 final TunnelName name = TunnelName.tunnelName(nameValue);
60 assertThat(name, is(notNullValue()));
61 assertThat(name.value(), is(nameValue));
62 }
63
64}