blob: f55205b549a1da7df0800c807e265f0426e3df35 [file] [log] [blame]
PRASHANTH SHIVANANJAPPA491b8af2016-04-27 19:23:24 +05301/*
2 * Copyright 2016-present 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.isis.io.isispacket.tlv;
17
18import org.jboss.netty.buffer.ChannelBuffer;
19import org.jboss.netty.buffer.ChannelBuffers;
20import org.junit.After;
21import org.junit.Before;
22import org.junit.Test;
23
24import static org.hamcrest.MatcherAssert.assertThat;
25import static org.hamcrest.Matchers.is;
26import static org.hamcrest.Matchers.notNullValue;
27
28/**
29 * Unit test class for PaddingTlv.
30 */
31public class PaddingTlvTest {
32
33 private final byte[] tlv = {0, 0, 0, 0, 0, 0, 0};
34 private PaddingTlv paddingTlv;
35 private TlvHeader tlvHeader;
36 private ChannelBuffer channelBuffer;
37 private byte[] result;
38
39 @Before
40 public void setUp() throws Exception {
41 tlvHeader = new TlvHeader();
42 paddingTlv = new PaddingTlv(tlvHeader);
43 }
44
45 @After
46 public void tearDown() throws Exception {
47 paddingTlv = null;
48 }
49
50 /**
51 * Tests readFrom() method.
52 */
53 @Test
54 public void testReadFrom() throws Exception {
55 channelBuffer = ChannelBuffers.copiedBuffer(tlv);
56 paddingTlv.readFrom(channelBuffer);
57 assertThat(paddingTlv, is(notNullValue()));
58 }
59
60 /**
61 * Tests asBytes() method.
62 */
63 @Test
64 public void testAsBytes() throws Exception {
65 channelBuffer = ChannelBuffers.copiedBuffer(tlv);
66 paddingTlv.readFrom(channelBuffer);
67 result = paddingTlv.asBytes();
68 assertThat(result, is(notNullValue()));
69 }
70
71 /**
72 * Tests toString() getter method.
73 */
74 @Test
75 public void testToString() throws Exception {
76 assertThat(paddingTlv.toString(), is(notNullValue()));
77 }
78}