blob: 4f2dbda74f8554a55c39e20748beb05065a708b0 [file] [log] [blame]
PRASHANTH SHIVANANJAPPA491b8af2016-04-27 19:23:24 +05301/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2016-present Open Networking Foundation
PRASHANTH SHIVANANJAPPA491b8af2016-04-27 19:23:24 +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.isis.io.isispacket.tlv.subtlv;
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.isis.io.isispacket.tlv.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 MaximumBandwidth.
31 */
32public class MaximumBandwidthTest {
33
34 private final byte[] packet = {0, 0, 0, 0};
35 private MaximumBandwidth maximumBandwidth;
36 private TlvHeader header;
37 private ChannelBuffer channelBuffer;
38 private byte[] result;
39
40 @Before
41 public void setUp() throws Exception {
42 maximumBandwidth = new MaximumBandwidth(new TlvHeader());
43 }
44
45 @After
46 public void tearDown() throws Exception {
47 maximumBandwidth = null;
48 header = null;
49 channelBuffer = null;
50 result = null;
51 }
52
53 /**
54 * Tests maximumBandwidth() setter method.
55 */
56 @Test
57 public void testSetMaximumBandwidth() throws Exception {
58 maximumBandwidth.setMaximumBandwidth(123456.00f);
59 assertThat(maximumBandwidth, is(notNullValue()));
60 }
61
62 /**
63 * Tests readFrom() method.
64 */
65 @Test
66 public void testReadFrom() throws Exception {
67 header = new TlvHeader();
68 header.setTlvType(6);
69 header.setTlvLength(4);
70 channelBuffer = ChannelBuffers.copiedBuffer(packet);
71 maximumBandwidth = new MaximumBandwidth(header);
72 maximumBandwidth.readFrom(channelBuffer);
73 assertThat(maximumBandwidth, is(notNullValue()));
74 }
75
76 /**
77 * Tests asBytes() method.
78 */
79 @Test
80 public void testAsBytes() throws Exception {
81 result = maximumBandwidth.asBytes();
82 assertThat(result, is(notNullValue()));
83 }
84
85 /**
86 * Tests to string method.
87 */
88 @Test
89 public void testToString() throws Exception {
90 assertThat(maximumBandwidth.toString(), is(notNullValue()));
91 }
92}