Thomas Vachuska | bf916ea | 2015-05-20 18:24:34 -0700 | [diff] [blame] | 1 | /* |
Brian O'Connor | 5ab426f | 2016-04-09 01:19:45 -0700 | [diff] [blame] | 2 | * Copyright 2015-present Open Networking Laboratory |
Thomas Vachuska | bf916ea | 2015-05-20 18:24:34 -0700 | [diff] [blame] | 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 | package org.onosproject.incubator.net.tunnel; |
jcc | 4a20a5f | 2015-04-30 15:43:39 +0800 | [diff] [blame] | 17 | |
| 18 | import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable; |
| 19 | |
| 20 | import org.junit.Test; |
| 21 | import org.onlab.packet.IpAddress; |
| 22 | import org.onosproject.core.ApplicationId; |
| 23 | import org.onosproject.core.DefaultApplicationId; |
| 24 | |
| 25 | import com.google.common.testing.EqualsTester; |
| 26 | |
| 27 | /** |
| 28 | * Test of order model entity. |
| 29 | */ |
| 30 | public class TunnelSubscriptionTest { |
| 31 | /** |
| 32 | * Checks that the Order class is immutable. |
| 33 | */ |
| 34 | @Test |
| 35 | public void testImmutability() { |
| 36 | assertThatClassIsImmutable(TunnelSubscription.class); |
| 37 | } |
| 38 | |
| 39 | /** |
| 40 | * Checks the operation of equals(), hashCode() and toString() methods. |
| 41 | */ |
| 42 | @Test |
| 43 | public void testEquality() { |
| 44 | TunnelEndPoint src = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(23423)); |
| 45 | TunnelEndPoint dst = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(32421)); |
| 46 | ApplicationId appId = new DefaultApplicationId(243, "test"); |
| 47 | ApplicationId appId2 = new DefaultApplicationId(2431, "test1"); |
Brian Stanke | 9a10897 | 2016-04-11 15:25:17 -0400 | [diff] [blame^] | 48 | TunnelId tunnelId = TunnelId.valueOf("41654654"); |
jcc | 4a20a5f | 2015-04-30 15:43:39 +0800 | [diff] [blame] | 49 | TunnelSubscription p1 = new TunnelSubscription(appId, src, dst, tunnelId, Tunnel.Type.VXLAN, |
| 50 | null); |
| 51 | TunnelSubscription p2 = new TunnelSubscription(appId, src, dst, tunnelId, Tunnel.Type.VXLAN, |
| 52 | null); |
| 53 | TunnelSubscription p3 = new TunnelSubscription(appId2, src, dst, tunnelId, Tunnel.Type.VXLAN, |
| 54 | null); |
| 55 | new EqualsTester().addEqualityGroup(p1, p2).addEqualityGroup(p3) |
| 56 | .testEquals(); |
| 57 | } |
| 58 | } |