blob: ad3b7e06253064d13be9b91e3a7886de3a4fefe2 [file] [log] [blame]
Kiran Ramachandra959353a2016-02-16 22:12:07 +05301/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2016-present Open Networking Laboratory
Kiran Ramachandra959353a2016-02-16 22:12:07 +05303 *
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.ospf.protocol.lsa;
17
18import org.junit.After;
19import org.junit.Before;
20import org.junit.Test;
21
22import static org.hamcrest.CoreMatchers.notNullValue;
23import static org.hamcrest.Matchers.is;
24import static org.junit.Assert.assertThat;
25
26/**
27 * Unit test class for Tlv Header.
28 */
29public class TlvHeaderTest {
30
31 private TlvHeader tlvHeader;
32 private byte[] result;
33
34
35 @Before
36 public void setUp() throws Exception {
37 tlvHeader = new TlvHeader();
38 }
39
40 @After
41 public void tearDown() throws Exception {
42 tlvHeader = null;
43 result = null;
44 }
45
46 /**
47 * Tests to string method.
48 */
49 @Test
50 public void testToString() throws Exception {
51 assertThat(tlvHeader.toString(), is(notNullValue()));
52 }
53
54 /**
55 * Tests tlvLength() getter method.
56 */
57 @Test
58 public void testGetTlvLength() throws Exception {
59 tlvHeader.setTlvLength(2);
60 assertThat(tlvHeader.tlvLength(), is(2));
61 }
62
63 /**
64 * Tests tlvLength() setter method.
65 */
66 @Test
67 public void testSetTlvLength() throws Exception {
68 tlvHeader.setTlvLength(2);
69 assertThat(tlvHeader.tlvLength(), is(2));
70 }
71
72 /**
73 * Tests tlvType() getter method.
74 */
75 @Test
76 public void testGetTlvType() throws Exception {
77 tlvHeader.setTlvType(2);
78 assertThat(tlvHeader.tlvType(), is(2));
79 }
80
81 /**
82 * Tests tlvType() setter method.
83 */
84 @Test
85 public void testSetTlvType() throws Exception {
86 tlvHeader.setTlvType(2);
87 assertThat(tlvHeader.tlvType(), is(2));
88 }
89
90 /**
91 * Tests getTlvHeaderAsByteArray() method.
92 */
93 @Test
94 public void testGetTlvHeaderAsByteArray() throws Exception {
95 result = tlvHeader.getTlvHeaderAsByteArray();
96 assertThat(result, is(notNullValue()));
97 }
98}