blob: f7fc5b1acbcbf05d03b970c8545221dba02d77ba [file] [log] [blame]
Ray Milkey85267002016-11-16 11:06:35 -08001/*
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 */
PRASHANTH SHIVANANJAPPA491b8af2016-04-27 19:23:24 +053016package org.onosproject.isis.io.isispacket.tlv.subtlv;
17
18import org.easymock.EasyMock;
19import org.jboss.netty.buffer.ChannelBuffer;
20import org.junit.After;
21import org.junit.Before;
22import org.junit.Test;
23import org.onosproject.isis.io.isispacket.tlv.TlvHeader;
24
25import java.util.List;
26
27import static org.hamcrest.MatcherAssert.assertThat;
28import static org.hamcrest.Matchers.is;
29import static org.hamcrest.Matchers.notNullValue;
30
31/**
32 * Unit test class for SubTlvToBytes.
33 */
34public class SubTlvToBytesTest {
35 private TlvHeader tlvHeader;
36 private ChannelBuffer channelBuffer;
37 private List<Byte> tlv;
38
39 @Before
40 public void setUp() throws Exception {
41 tlvHeader = new TlvHeader();
42 channelBuffer = EasyMock.createMock(ChannelBuffer.class);
43 }
44
45 @After
46 public void tearDown() throws Exception {
47 tlvHeader = null;
48 channelBuffer = null;
49 }
50
51 @Test
52 public void testTlvToBytes() throws Exception {
53 tlvHeader.setTlvLength(4);
54 tlvHeader.setTlvType(9);
55 AdministrativeGroup administrativeGroup = new AdministrativeGroup(tlvHeader);
56 tlv = SubTlvToBytes.tlvToBytes(administrativeGroup);
57 assertThat(tlv, is(notNullValue()));
58
59 tlvHeader = new TlvHeader();
60 tlvHeader.setTlvLength(4);
61 tlvHeader.setTlvType(5);
62 TrafficEngineeringMetric trafficEngineeringMetric = new TrafficEngineeringMetric(tlvHeader);
63 tlv = SubTlvToBytes.tlvToBytes(trafficEngineeringMetric);
64 assertThat(tlv, is(notNullValue()));
65
66 tlvHeader = new TlvHeader();
67 tlvHeader.setTlvLength(4);
68 tlvHeader.setTlvType(6);
69 MaximumBandwidth maximumBandwidth = new MaximumBandwidth(tlvHeader);
70 tlv = SubTlvToBytes.tlvToBytes(maximumBandwidth);
71 assertThat(tlv, is(notNullValue()));
72
73 tlvHeader = new TlvHeader();
74 tlvHeader.setTlvLength(4);
75 tlvHeader.setTlvType(7);
76 MaximumReservableBandwidth maximumReservableBandwidth = new MaximumReservableBandwidth(tlvHeader);
77 tlv = SubTlvToBytes.tlvToBytes(maximumReservableBandwidth);
78 assertThat(tlv, is(notNullValue()));
79
80 tlvHeader = new TlvHeader();
81 tlvHeader.setTlvLength(4);
82 tlvHeader.setTlvType(8);
83 UnreservedBandwidth unreservedBandwidth = new UnreservedBandwidth(tlvHeader);
84 tlv = SubTlvToBytes.tlvToBytes(unreservedBandwidth);
85 assertThat(tlv, is(notNullValue()));
86 }
Ray Milkey85267002016-11-16 11:06:35 -080087}