blob: 39bb72f43bf1047beafc88420d45fcad933628b4 [file] [log] [blame]
Jonathan Hart2a655752015-04-07 16:46:33 -07001/*
2 * Copyright 2015 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 */
16
17package org.onlab.packet;
18
19import org.junit.Before;
20import org.junit.Test;
21
22import java.nio.ByteBuffer;
23
24import static org.junit.Assert.assertEquals;
25
26/**
27 * Unit tests for LLC class.
28 */
29public class LLCTest {
30
31 private Deserializer<LLC> deserializer;
32
33 private byte dsap = 10;
34 private byte ssap = 20;
35 private byte ctrl = 30;
36
37 private byte[] bytes;
38
39 @Before
40 public void setUp() throws Exception {
41 deserializer = LLC.deserializer();
42
43 ByteBuffer bb = ByteBuffer.allocate(LLC.LLC_HEADER_LENGTH);
44
45 bb.put(dsap);
46 bb.put(ssap);
47 bb.put(ctrl);
48
49 bytes = bb.array();
50 }
51
52 @Test
53 public void testDeserializeBadInput() throws Exception {
54 PacketTestUtils.testDeserializeBadInput(deserializer);
55 }
56
57 @Test
58 public void testDeserializeTruncated() throws Exception {
59 PacketTestUtils.testDeserializeTruncated(deserializer, bytes);
60 }
61
62 @Test
63 public void testDeserialize() throws Exception {
64 LLC llc = deserializer.deserialize(bytes, 0, bytes.length);
65
66 assertEquals(dsap, llc.getDsap());
67 assertEquals(ssap, llc.getSsap());
68 assertEquals(ctrl, llc.getCtrl());
69 }
70}