blob: d23269c15d2f16e4994006e61cbe427bd640a6bc [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.linksubtype;
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;
23import org.onosproject.ospf.protocol.lsa.TlvHeader;
24
25import static org.hamcrest.MatcherAssert.assertThat;
26import static org.hamcrest.Matchers.is;
27import static org.hamcrest.Matchers.notNullValue;
28
29/**
30 * Unit test class for MaximumReservableBandwidth.
31 */
32public class MaximumReservableBandwidthTest {
33
34 private final byte[] packet = {0, 0, 0, 0};
35 private MaximumReservableBandwidth maximumReservableBandwidth;
36 private TlvHeader header;
37 private ChannelBuffer channelBuffer;
38 private byte[] result;
39
40 @Before
41 public void setUp() throws Exception {
42 maximumReservableBandwidth = new MaximumReservableBandwidth(new TlvHeader());
43 }
44
45 @After
46 public void tearDown() throws Exception {
47 maximumReservableBandwidth = null;
48 header = null;
49 channelBuffer = null;
50 result = null;
51 }
52
53
54 /**
55 * Tests maximumBandwidth() setter method.
56 */
57 @Test
58 public void testSetMaximumBandwidth() throws Exception {
59 maximumReservableBandwidth.setMaximumBandwidth(123456.78f);
60 assertThat(maximumReservableBandwidth, is(notNullValue()));
61 }
62
63 /**
64 * Tests readFrom() method.
65 */
66 @Test
67 public void testReadFrom() throws Exception {
68 header = new TlvHeader();
69 header.setTlvType(6);
70 header.setTlvLength(4);
71 channelBuffer = ChannelBuffers.copiedBuffer(packet);
72 maximumReservableBandwidth = new MaximumReservableBandwidth(header);
73 maximumReservableBandwidth.readFrom(channelBuffer);
74 assertThat(maximumReservableBandwidth, is(notNullValue()));
75 }
76
77 /**
78 * Tests asBytes() method.
79 */
80 @Test
81 public void testAsBytes() throws Exception {
82 result = maximumReservableBandwidth.asBytes();
83 assertThat(result, is(notNullValue()));
84 }
85
86
87 /**
88 * Tests getLinkSubTypeTlvBodyAsByteArray() method.
89 */
90 @Test
91 public void testGetLinkSubTypeTlvBodyAsByteArray() throws Exception {
92 result = maximumReservableBandwidth.getLinksubTypeTlvBodyAsByteArray();
93 assertThat(result, is(notNullValue()));
94 }
95
96 /**
97 * Tests to string method.
98 */
99 @Test
100 public void testToString() throws Exception {
101 assertThat(maximumReservableBandwidth.toString(), is(notNullValue()));
102 }
103}