blob: af76773c23a7d00e98370987b1f12fb991649de2 [file] [log] [blame]
Ray Milkey201f04b2017-09-25 10:13:19 -07001/*
2 * Copyright 2017-present Open Networking Foundation
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.net.behaviour;
18
19import org.junit.Test;
20import org.onlab.packet.MacAddress;
21import org.onosproject.net.ConnectPoint;
22import org.onosproject.net.NetTestTools;
23
24import com.google.common.testing.EqualsTester;
25
26import static org.hamcrest.MatcherAssert.assertThat;
27import static org.hamcrest.Matchers.is;
28import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
29
30public class TunnelEndPointTest {
31
32 private ConnectPoint cp1 = NetTestTools.connectPoint("cp1", 1);
33 private TunnelEndPoint<ConnectPoint> endPoint1 =
34 new TunnelEndPoint<>(cp1);
35 private TunnelEndPoint<ConnectPoint> sameAsEndPoint1 =
36 new TunnelEndPoint<>(cp1);
37
38 private ConnectPoint cp2 = NetTestTools.connectPoint("cp2", 2);
39 private TunnelEndPoint<ConnectPoint> endPoint2 =
40 new TunnelEndPoint<>(cp2);
41
42 private TunnelEndPoint<MacAddress> endPoint3 =
43 new TunnelEndPoint<>(MacAddress.BROADCAST);
44
45 @Test
46 public void testImmutability() {
47 assertThatClassIsImmutable(TunnelEndPoint.class);
48 }
49
50 @Test
51 public void testConstruction() {
52 assertThat(endPoint1.value(), is(cp1));
53 assertThat(endPoint1.strValue(), is(cp1.toString()));
54 }
55
56 @Test
57 public void testEquals() {
58 new EqualsTester()
59 .addEqualityGroup(endPoint1, sameAsEndPoint1)
60 .addEqualityGroup(endPoint2)
61 .addEqualityGroup(endPoint3)
62 .testEquals();
63 }
64}