blob: 9984315d3da83e2a19819a0ae2eacda578226216 [file] [log] [blame]
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07001/*
2 * Copyright 2014 Open Networking Laboratory
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 */
tom747a2132014-10-02 08:18:41 -070016package org.onlab.onos.net.topology;
17
18import com.google.common.testing.EqualsTester;
19import org.junit.Test;
20import org.onlab.onos.net.ConnectPoint;
21import org.onlab.onos.net.DefaultLink;
22import org.onlab.onos.net.DeviceId;
23import org.onlab.onos.net.Link;
24import org.onlab.onos.net.PortNumber;
25import org.onlab.onos.net.provider.ProviderId;
26
27import static org.junit.Assert.assertEquals;
28import static org.onlab.onos.net.DeviceId.deviceId;
29import static org.onlab.onos.net.PortNumber.portNumber;
30
31/**
32 * Tests of the topology graph edge.
33 */
34public class DefaultTopologyEdgeTest {
35
36 static final DeviceId D1 = deviceId("1");
37 static final DeviceId D2 = deviceId("2");
38 static final PortNumber P1 = portNumber(1);
39 static final PortNumber P2 = portNumber(2);
40
41 static final ConnectPoint CP1 = new ConnectPoint(D1, P1);
42 static final ConnectPoint CP2 = new ConnectPoint(D2, P1);
43 static final ConnectPoint CP3 = new ConnectPoint(D2, P1);
44 static final ConnectPoint CP4 = new ConnectPoint(D1, P2);
45
46 static final DefaultTopologyVertex V1 = new DefaultTopologyVertex(D1);
47 static final DefaultTopologyVertex V2 = new DefaultTopologyVertex(D2);
48
49 static final ProviderId PID = new ProviderId("foo", "bar");
50
Yuta HIGUCHI22102822014-11-12 23:09:59 -080051 /** D1:P1 -> D2:P1. */
tom747a2132014-10-02 08:18:41 -070052 static final Link L1 = new DefaultLink(PID, CP1, CP2, Link.Type.INDIRECT);
Yuta HIGUCHI22102822014-11-12 23:09:59 -080053 /** D2:P1 -> D1:P2. */
tom747a2132014-10-02 08:18:41 -070054 static final Link L2 = new DefaultLink(PID, CP3, CP4, Link.Type.INDIRECT);
55
56 @Test
57 public void basics() {
58 DefaultTopologyEdge e = new DefaultTopologyEdge(V1, V2, L1);
59 assertEquals("incorrect src", V1, e.src());
60 assertEquals("incorrect dst", V2, e.dst());
61 assertEquals("incorrect link", L1, e.link());
62
63 new EqualsTester()
64 .addEqualityGroup(new DefaultTopologyEdge(V1, V2, L1),
65 new DefaultTopologyEdge(V1, V2, L1))
66 .addEqualityGroup(new DefaultTopologyEdge(V2, V1, L2),
67 new DefaultTopologyEdge(V2, V1, L2))
68 .testEquals();
69 }
Yuta HIGUCHI885be1d2014-10-04 21:47:26 -070070}