blob: d934f7a6505150a2946a6ee0c17ab5206de021bf [file] [log] [blame]
Dmytro Titov8484ad12019-06-10 18:07:52 +05001/*
2 * Copyright 2019-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
17package org.onlab.packet;
18
19import org.junit.Before;
20import org.junit.Test;
21
22import static org.junit.Assert.assertEquals;
23
24/**
25 * Unit tests for the Data class.
26 */
27public class DataTest {
28
29 private static final int DATA_BUFFER_SIZE = 10;
30 private static final int DATA_LENGTH = 5;
31 private static byte[] dataBuffer = new byte[DATA_BUFFER_SIZE];
32
33 private Deserializer<Data> deserializer;
34
35 @Before
36 public void setUp() {
37 deserializer = Data.deserializer();
38 }
39
40 @Test
41 public void testDeserializePartOfBuffer() throws Exception {
42 Data data = deserializer.deserialize(dataBuffer, 0, DATA_LENGTH);
43
44 assertEquals(DATA_LENGTH, data.getData().length);
45 }
46
47}