blob: 1e098eed3031d1979d4764200df397c1dc78d3db [file] [log] [blame]
Charles Chan64c2dfd2018-07-24 11:58:08 -07001/*
2 * Copyright 2018-present Open Networking Foundation
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 */
17
18package org.onlab.packet.lacp;
19
20import com.google.common.io.Resources;
21import org.junit.Before;
22import org.junit.Test;
23
24import static org.junit.Assert.assertArrayEquals;
25import static org.junit.Assert.assertEquals;
26
27public class LacpCollectorTlvTest {
28 private static final String PACKET_DUMP = "collectorinfo.bin";
29
30 private byte[] data;
31
32 private static final short COLLECTOR_MAX_DELAY = (short) 32768;
33
34 static final LacpCollectorTlv COLLECTOR_TLV = new LacpCollectorTlv()
35 .setCollectorMaxDelay(COLLECTOR_MAX_DELAY);
36
37 @Before
38 public void setUp() throws Exception {
39 data = Resources.toByteArray(LacpCollectorTlvTest.class.getResource(PACKET_DUMP));
40 }
41
42 @Test
43 public void deserializer() throws Exception {
44 LacpCollectorTlv lacpCollectorTlv = LacpCollectorTlv.deserializer().deserialize(data, 0, data.length);
45 assertEquals(COLLECTOR_MAX_DELAY, lacpCollectorTlv.getCollectorMaxDelay());
46
47 }
48
49 @Test
50 public void serialize() {
51 assertArrayEquals(data, COLLECTOR_TLV.serialize());
52 }
53}