blob: e9aa30ca15194b9d7633ab2321e5aad5e773b6a8 [file] [log] [blame]
Thomas Vachuska58de4162015-09-10 16:15:33 -07001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2015-present Open Networking Laboratory
Thomas Vachuska58de4162015-09-10 16:15:33 -07003 *
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 Vachuskabf916ea2015-05-20 18:24:34 -070016package org.onosproject.incubator.net.tunnel;
jcc4a20a5f2015-04-30 15:43:39 +080017
18import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
19
20import org.junit.Test;
21import org.onlab.packet.IpAddress;
22import org.onosproject.core.DefaultGroupId;
23import org.onosproject.net.provider.ProviderId;
24
25import com.google.common.testing.EqualsTester;
26
27/**
28 * Test of the default tunnel model entity.
29 */
30public 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));
45 DefaultGroupId groupId = new DefaultGroupId(92034);
46 TunnelName tunnelName = TunnelName.tunnelName("TunnelName");
Brian Stanke9a108972016-04-11 15:25:17 -040047 TunnelId tunnelId = TunnelId.valueOf("41654654");
jcc4a20a5f2015-04-30 15:43:39 +080048 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,
samuel7a5691a2015-05-23 00:36:32 +080052 tunnelName, null);
jcc4a20a5f2015-04-30 15:43:39 +080053 Tunnel p2 = new DefaultTunnel(producerName1, src, dst, Tunnel.Type.VXLAN,
54 Tunnel.State.ACTIVE, groupId, tunnelId,
samuel7a5691a2015-05-23 00:36:32 +080055 tunnelName, null);
jcc4a20a5f2015-04-30 15:43:39 +080056 Tunnel p3 = new DefaultTunnel(producerName2, src, dst, Tunnel.Type.OCH,
57 Tunnel.State.ACTIVE, groupId, tunnelId,
samuel7a5691a2015-05-23 00:36:32 +080058 tunnelName, null);
jcc4a20a5f2015-04-30 15:43:39 +080059 new EqualsTester().addEqualityGroup(p1, p2).addEqualityGroup(p3)
60 .testEquals();
61 }
62}