blob: 1bc114f85db36ba4ea5cbbdbff180a251a403cfc [file] [log] [blame]
Jian Li5c5ddcd2016-02-10 22:54:04 -08001/*
2 * Copyright 2016 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 */
16package org.onosproject.cpman.message;
17
18import org.junit.Test;
19import org.onosproject.cpman.DefaultControlMessage;
20
21import static org.hamcrest.Matchers.is;
22import static org.junit.Assert.assertThat;
23import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutableBaseClass;
24import static org.onosproject.cpman.ControlMessage.Type.INBOUND_PACKET;
25
26/**
27 * Unit tests for the default control message class.
28 */
29public class DefaultControlMessageTest {
30
31 /**
32 * Checks that the DefaultControlMessage class is immutable but can be
33 * inherited from.
34 */
35 @Test
36 public void testImmutability() {
37 assertThatClassIsImmutableBaseClass(DefaultControlMessage.class);
38 }
39
40 /**
41 * Tests creation of a DefaultControlMessage using a regular constructor.
42 */
43 @Test
44 public void testBasic() {
45 final DefaultControlMessage cm =
46 new DefaultControlMessage(INBOUND_PACKET, 0L, 1L, 2L, 3L);
47 assertThat(cm.type(), is(INBOUND_PACKET));
48 assertThat(cm.load(), is(0L));
49 assertThat(cm.rate(), is(1L));
50 assertThat(cm.count(), is(2L));
51 assertThat(cm.timeStamp(), is(3L));
52 }
53}