blob: bf34e1c85815c4671da74b4ec8813df8cb953592 [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
51 static final Link L1 = new DefaultLink(PID, CP1, CP2, Link.Type.INDIRECT);
52 static final Link L2 = new DefaultLink(PID, CP3, CP4, Link.Type.INDIRECT);
53
54 @Test
55 public void basics() {
56 DefaultTopologyEdge e = new DefaultTopologyEdge(V1, V2, L1);
57 assertEquals("incorrect src", V1, e.src());
58 assertEquals("incorrect dst", V2, e.dst());
59 assertEquals("incorrect link", L1, e.link());
60
61 new EqualsTester()
62 .addEqualityGroup(new DefaultTopologyEdge(V1, V2, L1),
63 new DefaultTopologyEdge(V1, V2, L1))
64 .addEqualityGroup(new DefaultTopologyEdge(V2, V1, L2),
65 new DefaultTopologyEdge(V2, V1, L2))
66 .testEquals();
67 }
Yuta HIGUCHI885be1d2014-10-04 21:47:26 -070068}