Thomas Vachuska | 58de416 | 2015-09-10 16:15:33 -0700 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2015-present Open Networking Foundation |
Thomas Vachuska | 58de416 | 2015-09-10 16:15:33 -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 | */ |
Thomas Vachuska | bf916ea | 2015-05-20 18:24:34 -0700 | [diff] [blame] | 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; |
Yi Tseng | fa394de | 2017-02-01 11:26:40 -0800 | [diff] [blame] | 22 | import org.onosproject.core.GroupId; |
jcc | 4a20a5f | 2015-04-30 15:43:39 +0800 | [diff] [blame] | 23 | import org.onosproject.net.provider.ProviderId; |
| 24 | |
| 25 | import com.google.common.testing.EqualsTester; |
| 26 | |
| 27 | /** |
| 28 | * Test of the default tunnel model entity. |
| 29 | */ |
| 30 | public class DefaultTunnelTest { |
| 31 | /** |
| 32 | * Checks that the Order class is immutable. |
| 33 | */ |
| 34 | @Test |
| 35 | public void testImmutability() { |
| 36 | assertThatClassIsImmutable(DefaultTunnel.class); |
| 37 | } |
| 38 | |
| 39 | @Test |
| 40 | public void testEquality() { |
| 41 | TunnelEndPoint src = IpTunnelEndPoint.ipTunnelPoint(IpAddress |
| 42 | .valueOf(23423)); |
| 43 | TunnelEndPoint dst = IpTunnelEndPoint.ipTunnelPoint(IpAddress |
| 44 | .valueOf(32421)); |
Yi Tseng | fa394de | 2017-02-01 11:26:40 -0800 | [diff] [blame] | 45 | GroupId groupId = new GroupId(92034); |
jcc | 4a20a5f | 2015-04-30 15:43:39 +0800 | [diff] [blame] | 46 | TunnelName tunnelName = TunnelName.tunnelName("TunnelName"); |
Brian Stanke | 9a10897 | 2016-04-11 15:25:17 -0400 | [diff] [blame] | 47 | TunnelId tunnelId = TunnelId.valueOf("41654654"); |
jcc | 4a20a5f | 2015-04-30 15:43:39 +0800 | [diff] [blame] | 48 | ProviderId producerName1 = new ProviderId("producer1", "13"); |
| 49 | ProviderId producerName2 = new ProviderId("producer2", "13"); |
| 50 | Tunnel p1 = new DefaultTunnel(producerName1, src, dst, Tunnel.Type.VXLAN, |
| 51 | Tunnel.State.ACTIVE, groupId, tunnelId, |
samuel | 7a5691a | 2015-05-23 00:36:32 +0800 | [diff] [blame] | 52 | tunnelName, null); |
jcc | 4a20a5f | 2015-04-30 15:43:39 +0800 | [diff] [blame] | 53 | Tunnel p2 = new DefaultTunnel(producerName1, src, dst, Tunnel.Type.VXLAN, |
| 54 | Tunnel.State.ACTIVE, groupId, tunnelId, |
samuel | 7a5691a | 2015-05-23 00:36:32 +0800 | [diff] [blame] | 55 | tunnelName, null); |
jcc | 4a20a5f | 2015-04-30 15:43:39 +0800 | [diff] [blame] | 56 | Tunnel p3 = new DefaultTunnel(producerName2, src, dst, Tunnel.Type.OCH, |
| 57 | Tunnel.State.ACTIVE, groupId, tunnelId, |
samuel | 7a5691a | 2015-05-23 00:36:32 +0800 | [diff] [blame] | 58 | tunnelName, null); |
jcc | 4a20a5f | 2015-04-30 15:43:39 +0800 | [diff] [blame] | 59 | new EqualsTester().addEqualityGroup(p1, p2).addEqualityGroup(p3) |
| 60 | .testEquals(); |
| 61 | } |
| 62 | } |