PRASHANTH SHIVANANJAPPA | 491b8af | 2016-04-27 19:23:24 +0530 | [diff] [blame^] | 1 | package org.onosproject.isis.io.isispacket.tlv.subtlv; |
| 2 | |
| 3 | import org.easymock.EasyMock; |
| 4 | import org.jboss.netty.buffer.ChannelBuffer; |
| 5 | import org.junit.After; |
| 6 | import org.junit.Before; |
| 7 | import org.junit.Test; |
| 8 | import org.onosproject.isis.io.isispacket.tlv.TlvHeader; |
| 9 | |
| 10 | import java.util.List; |
| 11 | |
| 12 | import static org.hamcrest.MatcherAssert.assertThat; |
| 13 | import static org.hamcrest.Matchers.is; |
| 14 | import static org.hamcrest.Matchers.notNullValue; |
| 15 | |
| 16 | /** |
| 17 | * Unit test class for SubTlvToBytes. |
| 18 | */ |
| 19 | public class SubTlvToBytesTest { |
| 20 | private TlvHeader tlvHeader; |
| 21 | private ChannelBuffer channelBuffer; |
| 22 | private List<Byte> tlv; |
| 23 | |
| 24 | @Before |
| 25 | public void setUp() throws Exception { |
| 26 | tlvHeader = new TlvHeader(); |
| 27 | channelBuffer = EasyMock.createMock(ChannelBuffer.class); |
| 28 | } |
| 29 | |
| 30 | @After |
| 31 | public void tearDown() throws Exception { |
| 32 | tlvHeader = null; |
| 33 | channelBuffer = null; |
| 34 | } |
| 35 | |
| 36 | @Test |
| 37 | public void testTlvToBytes() throws Exception { |
| 38 | tlvHeader.setTlvLength(4); |
| 39 | tlvHeader.setTlvType(9); |
| 40 | AdministrativeGroup administrativeGroup = new AdministrativeGroup(tlvHeader); |
| 41 | tlv = SubTlvToBytes.tlvToBytes(administrativeGroup); |
| 42 | assertThat(tlv, is(notNullValue())); |
| 43 | |
| 44 | tlvHeader = new TlvHeader(); |
| 45 | tlvHeader.setTlvLength(4); |
| 46 | tlvHeader.setTlvType(5); |
| 47 | TrafficEngineeringMetric trafficEngineeringMetric = new TrafficEngineeringMetric(tlvHeader); |
| 48 | tlv = SubTlvToBytes.tlvToBytes(trafficEngineeringMetric); |
| 49 | assertThat(tlv, is(notNullValue())); |
| 50 | |
| 51 | tlvHeader = new TlvHeader(); |
| 52 | tlvHeader.setTlvLength(4); |
| 53 | tlvHeader.setTlvType(6); |
| 54 | MaximumBandwidth maximumBandwidth = new MaximumBandwidth(tlvHeader); |
| 55 | tlv = SubTlvToBytes.tlvToBytes(maximumBandwidth); |
| 56 | assertThat(tlv, is(notNullValue())); |
| 57 | |
| 58 | tlvHeader = new TlvHeader(); |
| 59 | tlvHeader.setTlvLength(4); |
| 60 | tlvHeader.setTlvType(7); |
| 61 | MaximumReservableBandwidth maximumReservableBandwidth = new MaximumReservableBandwidth(tlvHeader); |
| 62 | tlv = SubTlvToBytes.tlvToBytes(maximumReservableBandwidth); |
| 63 | assertThat(tlv, is(notNullValue())); |
| 64 | |
| 65 | tlvHeader = new TlvHeader(); |
| 66 | tlvHeader.setTlvLength(4); |
| 67 | tlvHeader.setTlvType(8); |
| 68 | UnreservedBandwidth unreservedBandwidth = new UnreservedBandwidth(tlvHeader); |
| 69 | tlv = SubTlvToBytes.tlvToBytes(unreservedBandwidth); |
| 70 | assertThat(tlv, is(notNullValue())); |
| 71 | } |
| 72 | } |