Ray Milkey | 201f04b | 2017-09-25 10:13:19 -0700 | [diff] [blame] | 1 | /* |
| 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 | |
| 17 | package org.onosproject.net.behaviour; |
| 18 | |
| 19 | import org.junit.Test; |
| 20 | import org.onlab.packet.MacAddress; |
| 21 | import org.onosproject.net.ConnectPoint; |
| 22 | import org.onosproject.net.NetTestTools; |
| 23 | |
| 24 | import com.google.common.testing.EqualsTester; |
| 25 | |
| 26 | import static org.hamcrest.MatcherAssert.assertThat; |
| 27 | import static org.hamcrest.Matchers.is; |
| 28 | import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable; |
| 29 | |
| 30 | public 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 | } |