Ray Milkey | 8f7feed | 2015-10-23 15:08:47 -0700 | [diff] [blame] | 1 | /* |
Brian O'Connor | 5ab426f | 2016-04-09 01:19:45 -0700 | [diff] [blame] | 2 | * Copyright 2015-present Open Networking Laboratory |
Ray Milkey | 8f7feed | 2015-10-23 15:08:47 -0700 | [diff] [blame] | 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 | */ |
| 16 | package org.onosproject.net.packet; |
| 17 | |
| 18 | import org.junit.Test; |
| 19 | |
| 20 | import static org.hamcrest.MatcherAssert.assertThat; |
| 21 | import static org.hamcrest.Matchers.greaterThanOrEqualTo; |
| 22 | import static org.hamcrest.Matchers.is; |
| 23 | |
| 24 | /** |
| 25 | * Unit tests for PacketEvent class. |
| 26 | */ |
| 27 | public 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 | } |