Charles Chan | 64c2dfd | 2018-07-24 11:58:08 -0700 | [diff] [blame] | 1 | /* |
| 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 | |
| 18 | package org.onlab.packet.lacp; |
| 19 | |
| 20 | import com.google.common.io.Resources; |
| 21 | import org.junit.Before; |
| 22 | import org.junit.Test; |
| 23 | |
| 24 | import static org.junit.Assert.assertArrayEquals; |
| 25 | import static org.junit.Assert.assertEquals; |
| 26 | |
| 27 | public 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 | } |