Thomas Vachuska | bf916ea | 2015-05-20 18:24:34 -0700 | [diff] [blame] | 1 | package org.onosproject.incubator.net.tunnel; |
jcc | 4a20a5f | 2015-04-30 15:43:39 +0800 | [diff] [blame] | 2 | |
| 3 | import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable; |
| 4 | |
| 5 | import org.junit.Test; |
| 6 | import org.onlab.packet.IpAddress; |
| 7 | import org.onosproject.core.DefaultGroupId; |
| 8 | import org.onosproject.net.provider.ProviderId; |
| 9 | |
| 10 | import com.google.common.testing.EqualsTester; |
| 11 | |
| 12 | /** |
| 13 | * Test of the default tunnel model entity. |
| 14 | */ |
| 15 | public class DefaultTunnelTest { |
| 16 | /** |
| 17 | * Checks that the Order class is immutable. |
| 18 | */ |
| 19 | @Test |
| 20 | public void testImmutability() { |
| 21 | assertThatClassIsImmutable(DefaultTunnel.class); |
| 22 | } |
| 23 | |
| 24 | @Test |
| 25 | public void testEquality() { |
| 26 | TunnelEndPoint src = IpTunnelEndPoint.ipTunnelPoint(IpAddress |
| 27 | .valueOf(23423)); |
| 28 | TunnelEndPoint dst = IpTunnelEndPoint.ipTunnelPoint(IpAddress |
| 29 | .valueOf(32421)); |
| 30 | DefaultGroupId groupId = new DefaultGroupId(92034); |
| 31 | TunnelName tunnelName = TunnelName.tunnelName("TunnelName"); |
| 32 | TunnelId tunnelId = TunnelId.valueOf(41654654); |
| 33 | ProviderId producerName1 = new ProviderId("producer1", "13"); |
| 34 | ProviderId producerName2 = new ProviderId("producer2", "13"); |
| 35 | Tunnel p1 = new DefaultTunnel(producerName1, src, dst, Tunnel.Type.VXLAN, |
| 36 | Tunnel.State.ACTIVE, groupId, tunnelId, |
samuel | 7a5691a | 2015-05-23 00:36:32 +0800 | [diff] [blame^] | 37 | tunnelName, null); |
jcc | 4a20a5f | 2015-04-30 15:43:39 +0800 | [diff] [blame] | 38 | Tunnel p2 = new DefaultTunnel(producerName1, src, dst, Tunnel.Type.VXLAN, |
| 39 | Tunnel.State.ACTIVE, groupId, tunnelId, |
samuel | 7a5691a | 2015-05-23 00:36:32 +0800 | [diff] [blame^] | 40 | tunnelName, null); |
jcc | 4a20a5f | 2015-04-30 15:43:39 +0800 | [diff] [blame] | 41 | Tunnel p3 = new DefaultTunnel(producerName2, src, dst, Tunnel.Type.OCH, |
| 42 | Tunnel.State.ACTIVE, groupId, tunnelId, |
samuel | 7a5691a | 2015-05-23 00:36:32 +0800 | [diff] [blame^] | 43 | tunnelName, null); |
jcc | 4a20a5f | 2015-04-30 15:43:39 +0800 | [diff] [blame] | 44 | new EqualsTester().addEqualityGroup(p1, p2).addEqualityGroup(p3) |
| 45 | .testEquals(); |
| 46 | } |
| 47 | } |