blob: a71779e7f26b9f04de46f49c8919ccde92adcc93 [file] [log] [blame]
Ray Milkey8f7feed2015-10-23 15:08:47 -07001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2015-present Open Networking Laboratory
Ray Milkey8f7feed2015-10-23 15:08:47 -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 */
16package org.onosproject.net.packet;
17
18import org.junit.Test;
19
20import static org.hamcrest.MatcherAssert.assertThat;
21import static org.hamcrest.Matchers.greaterThanOrEqualTo;
22import static org.hamcrest.Matchers.is;
23
24/**
25 * Unit tests for PacketEvent class.
26 */
27public class PacketEventTest {
28
29 OutboundPacket packet;
30
31 @Test
32 public void testConstruction1() {
33 long time = System.currentTimeMillis();
34 PacketEvent event = new PacketEvent(PacketEvent.Type.EMIT, packet);
35
36 assertThat(event.type(), is(PacketEvent.Type.EMIT));
37 assertThat(event.subject(), is(packet));
38 assertThat(event.time(), greaterThanOrEqualTo(time));
39 }
40
41 @Test
42 public void testConstruction2() {
43 long time = 12345678;
44 PacketEvent event = new PacketEvent(PacketEvent.Type.EMIT, packet, time);
45
46 assertThat(event.type(), is(PacketEvent.Type.EMIT));
47 assertThat(event.subject(), is(packet));
48 assertThat(event.time(), is(time));
49 }
50
51}