blob: 725ca33b59b2abbda3d3509153a1554f5e0ec5b6 [file] [log] [blame]
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2014-present Open Networking Laboratory
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -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 */
Brian O'Connorabafb502014-12-02 22:26:20 -080016package org.onosproject.net.link;
tomc0ccfb22014-09-08 00:41:32 -070017
18import org.junit.Test;
Brian O'Connorabafb502014-12-02 22:26:20 -080019import org.onosproject.event.AbstractEventTest;
20import org.onosproject.net.ConnectPoint;
21import org.onosproject.net.DefaultLink;
22import org.onosproject.net.Link;
23import org.onosproject.net.provider.ProviderId;
tomc0ccfb22014-09-08 00:41:32 -070024
Brian O'Connorabafb502014-12-02 22:26:20 -080025import static org.onosproject.net.DeviceId.deviceId;
26import static org.onosproject.net.PortNumber.portNumber;
tomc0ccfb22014-09-08 00:41:32 -070027
28/**
29 * Tests of the device event.
30 */
31public class LinkEventTest extends AbstractEventTest {
32
33 private Link createLink() {
Ray Milkey2693bda2016-01-22 16:08:14 -080034 return DefaultLink.builder()
35 .providerId(new ProviderId("of", "foo"))
36 .src(new ConnectPoint(deviceId("of:foo"), portNumber(1)))
37 .dst(new ConnectPoint(deviceId("of:bar"), portNumber(2)))
38 .type(Link.Type.INDIRECT)
39 .build();
tomc0ccfb22014-09-08 00:41:32 -070040 }
41
42 @Test
43 public void withTime() {
44 Link link = createLink();
45 LinkEvent event = new LinkEvent(LinkEvent.Type.LINK_ADDED, link, 123L);
46 validateEvent(event, LinkEvent.Type.LINK_ADDED, link, 123L);
47 }
48
49 @Test
50 public void withoutTime() {
51 Link link = createLink();
52 long before = System.currentTimeMillis();
53 LinkEvent event = new LinkEvent(LinkEvent.Type.LINK_ADDED, link);
54 long after = System.currentTimeMillis();
55 validateEvent(event, LinkEvent.Type.LINK_ADDED, link, before, after);
56 }
57
58}