blob: 5523c1946c4d915ab4610e53f2f0d01c5eac48f6 [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 */
tomc0ccfb22014-09-08 00:41:32 -070016package org.onlab.onos.net.link;
17
18import org.junit.Test;
19import org.onlab.onos.event.AbstractEventTest;
20import org.onlab.onos.net.ConnectPoint;
21import org.onlab.onos.net.DefaultLink;
22import org.onlab.onos.net.Link;
23import org.onlab.onos.net.provider.ProviderId;
24
25import static org.onlab.onos.net.DeviceId.deviceId;
26import static org.onlab.onos.net.PortNumber.portNumber;
27
28/**
29 * Tests of the device event.
30 */
31public class LinkEventTest extends AbstractEventTest {
32
33 private Link createLink() {
tom7e02cda2014-09-18 12:05:46 -070034 return new DefaultLink(new ProviderId("of", "foo"),
tomc0ccfb22014-09-08 00:41:32 -070035 new ConnectPoint(deviceId("of:foo"), portNumber(1)),
36 new ConnectPoint(deviceId("of:bar"), portNumber(2)),
37 Link.Type.INDIRECT);
38 }
39
40 @Test
41 public void withTime() {
42 Link link = createLink();
43 LinkEvent event = new LinkEvent(LinkEvent.Type.LINK_ADDED, link, 123L);
44 validateEvent(event, LinkEvent.Type.LINK_ADDED, link, 123L);
45 }
46
47 @Test
48 public void withoutTime() {
49 Link link = createLink();
50 long before = System.currentTimeMillis();
51 LinkEvent event = new LinkEvent(LinkEvent.Type.LINK_ADDED, link);
52 long after = System.currentTimeMillis();
53 validateEvent(event, LinkEvent.Type.LINK_ADDED, link, before, after);
54 }
55
56}