bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 1 | /* |
Brian O'Connor | 5ab426f | 2016-04-09 01:19:45 -0700 | [diff] [blame] | 2 | * Copyright 2015-present Open Networking Laboratory |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 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 | */ |
Sho SHIMIZU | 3559c31 | 2015-11-04 14:59:31 -0800 | [diff] [blame] | 16 | package org.onosproject.pcepio.protocol; |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 17 | |
| 18 | import org.jboss.netty.buffer.ChannelBuffer; |
| 19 | import org.jboss.netty.buffer.ChannelBuffers; |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 20 | import org.junit.Test; |
Mahesh Poojary S | f1bbd36 | 2016-02-25 18:19:59 +0530 | [diff] [blame] | 21 | import org.onosproject.pcepio.exceptions.PcepOutOfBoundMessageException; |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 22 | import org.onosproject.pcepio.exceptions.PcepParseException; |
Sho SHIMIZU | 3559c31 | 2015-11-04 14:59:31 -0800 | [diff] [blame] | 23 | |
| 24 | import static org.hamcrest.MatcherAssert.assertThat; |
| 25 | import static org.hamcrest.Matchers.instanceOf; |
| 26 | import static org.hamcrest.core.Is.is; |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 27 | |
bharat saraswal | b4e5cbe | 2015-09-02 19:33:20 +0530 | [diff] [blame] | 28 | public class PcepReportMsgExtTest { |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 29 | |
| 30 | /** |
| 31 | * This test case checks forSRP Object,LSP Object(symbolic path tlv),ERO Object |
| 32 | * SRP Object,LSP Object(symbolic path tlv,ERO Object,LSPA Object,BandWidth Object,Metric-list,RRO Object |
| 33 | * in PcRpt message. |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 34 | */ |
| 35 | @Test |
Mahesh Poojary S | f1bbd36 | 2016-02-25 18:19:59 +0530 | [diff] [blame] | 36 | public void reportMessageTest39() throws PcepParseException, PcepOutOfBoundMessageException { |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 37 | |
| 38 | byte[] reportMsg = new byte[] {0x20, 0x0a, 0x00, (byte) 0x98, |
| 39 | 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP object |
bharat saraswal | b4e5cbe | 2015-09-02 19:33:20 +0530 | [diff] [blame] | 40 | 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 41 | 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //symbolic path tlv |
| 42 | 0x07, 0x10, 0x00, 0x14, //ERO Object |
bharat saraswal | b4e5cbe | 2015-09-02 19:33:20 +0530 | [diff] [blame] | 43 | 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00, |
| 44 | 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00, |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 45 | 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP object |
bharat saraswal | b4e5cbe | 2015-09-02 19:33:20 +0530 | [diff] [blame] | 46 | 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 47 | 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //symbolic path tlv |
| 48 | 0x07, 0x10, 0x00, 0x14, //ERO object |
bharat saraswal | b4e5cbe | 2015-09-02 19:33:20 +0530 | [diff] [blame] | 49 | 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00, |
| 50 | 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00, |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 51 | 0x08, 0x10, 0x00, 0x34, 0x01, 0x08, 0x11, 0x01, //RRO object |
| 52 | 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, |
| 53 | 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x06, 0x06, |
| 54 | 0x06, 0x06, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01, |
| 55 | 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01, |
| 56 | 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x05, 0x05, 0x05, 0x05, 0x04, 0x00}; |
| 57 | |
| 58 | byte[] testReportMsg = {0}; |
| 59 | ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); |
| 60 | buffer.writeBytes(reportMsg); |
| 61 | |
| 62 | PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); |
| 63 | PcepMessage message = null; |
| 64 | |
| 65 | message = reader.readFrom(buffer); |
Priyanka bhaskar | 3e1a697 | 2015-08-27 15:31:54 +0530 | [diff] [blame] | 66 | assertThat(message, instanceOf(PcepReportMsg.class)); |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 67 | ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); |
| 68 | message.writeTo(buf); |
| 69 | |
Priyanka bhaskar | 3e1a697 | 2015-08-27 15:31:54 +0530 | [diff] [blame] | 70 | int readLen = buf.writerIndex(); |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 71 | testReportMsg = new byte[readLen]; |
| 72 | buf.readBytes(testReportMsg, 0, readLen); |
| 73 | |
Priyanka bhaskar | 3e1a697 | 2015-08-27 15:31:54 +0530 | [diff] [blame] | 74 | assertThat(testReportMsg, is(reportMsg)); |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 75 | } |
| 76 | |
| 77 | /** |
| 78 | * This test case checks for SRP Object,LSP Object(symbolic path tlv),ERO Object |
| 79 | * SRP Object,LSP Object(symbolic path tlv),ERO Object |
| 80 | * in PcRpt message. |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 81 | */ |
| 82 | @Test |
Mahesh Poojary S | f1bbd36 | 2016-02-25 18:19:59 +0530 | [diff] [blame] | 83 | public void reportMessageTest40() throws PcepParseException, PcepOutOfBoundMessageException { |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 84 | |
| 85 | byte[] reportMsg = new byte[] {0x20, 0x0a, 0x00, (byte) 0x64, |
| 86 | 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP object |
bharat saraswal | b4e5cbe | 2015-09-02 19:33:20 +0530 | [diff] [blame] | 87 | 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 88 | 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //symbolic path tlv |
| 89 | 0x07, 0x10, 0x00, 0x14, //ERO object |
bharat saraswal | b4e5cbe | 2015-09-02 19:33:20 +0530 | [diff] [blame] | 90 | 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00, |
| 91 | 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00, |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 92 | 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP object |
bharat saraswal | b4e5cbe | 2015-09-02 19:33:20 +0530 | [diff] [blame] | 93 | 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 94 | 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //symbolic path tlv |
| 95 | 0x07, 0x10, 0x00, 0x14, //ERO object |
bharat saraswal | b4e5cbe | 2015-09-02 19:33:20 +0530 | [diff] [blame] | 96 | 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00, |
| 97 | 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00}; |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 98 | |
| 99 | byte[] testReportMsg = {0}; |
| 100 | ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); |
| 101 | buffer.writeBytes(reportMsg); |
| 102 | |
| 103 | PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); |
| 104 | PcepMessage message = null; |
| 105 | |
| 106 | message = reader.readFrom(buffer); |
Priyanka bhaskar | 3e1a697 | 2015-08-27 15:31:54 +0530 | [diff] [blame] | 107 | assertThat(message, instanceOf(PcepReportMsg.class)); |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 108 | ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); |
| 109 | message.writeTo(buf); |
| 110 | |
Priyanka bhaskar | 3e1a697 | 2015-08-27 15:31:54 +0530 | [diff] [blame] | 111 | int readLen = buf.writerIndex(); |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 112 | testReportMsg = new byte[readLen]; |
| 113 | buf.readBytes(testReportMsg, 0, readLen); |
| 114 | |
Priyanka bhaskar | 3e1a697 | 2015-08-27 15:31:54 +0530 | [diff] [blame] | 115 | assertThat(testReportMsg, is(reportMsg)); |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 116 | } |
| 117 | |
| 118 | /** |
| 119 | * This test case checks for SRP Object,LSP Object(symbolic path tlv),ERO Object,LSPA Object |
| 120 | * SRP Object,LSP Object(symbolic path tlv),ERO Object,LSPA Object |
| 121 | * in PcRpt message. |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 122 | */ |
| 123 | @Test |
Mahesh Poojary S | f1bbd36 | 2016-02-25 18:19:59 +0530 | [diff] [blame] | 124 | public void reportMessageTest41() throws PcepParseException, PcepOutOfBoundMessageException { |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 125 | |
| 126 | byte[] reportMsg = new byte[] {0x20, 0x0a, 0x00, (byte) 0x8c, |
| 127 | 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP object |
bharat saraswal | b4e5cbe | 2015-09-02 19:33:20 +0530 | [diff] [blame] | 128 | 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 129 | 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //symbolic path tlv |
| 130 | 0x07, 0x10, 0x00, 0x14, //ERO object |
bharat saraswal | b4e5cbe | 2015-09-02 19:33:20 +0530 | [diff] [blame] | 131 | 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00, |
| 132 | 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00, |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 133 | 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object |
| 134 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 135 | 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP object |
bharat saraswal | b4e5cbe | 2015-09-02 19:33:20 +0530 | [diff] [blame] | 136 | 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 137 | 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //symbolic path tlv |
| 138 | 0x07, 0x10, 0x00, 0x14, //ERO object |
bharat saraswal | b4e5cbe | 2015-09-02 19:33:20 +0530 | [diff] [blame] | 139 | 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00, |
| 140 | 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00, |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 141 | 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, //LSPA object |
| 142 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; |
| 143 | |
| 144 | byte[] testReportMsg = {0}; |
| 145 | ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); |
| 146 | buffer.writeBytes(reportMsg); |
| 147 | |
| 148 | PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); |
| 149 | PcepMessage message = null; |
| 150 | |
| 151 | message = reader.readFrom(buffer); |
Priyanka bhaskar | 3e1a697 | 2015-08-27 15:31:54 +0530 | [diff] [blame] | 152 | assertThat(message, instanceOf(PcepReportMsg.class)); |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 153 | ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); |
| 154 | message.writeTo(buf); |
| 155 | |
Priyanka bhaskar | 3e1a697 | 2015-08-27 15:31:54 +0530 | [diff] [blame] | 156 | int readLen = buf.writerIndex(); |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 157 | testReportMsg = new byte[readLen]; |
| 158 | buf.readBytes(testReportMsg, 0, readLen); |
| 159 | |
Priyanka bhaskar | 3e1a697 | 2015-08-27 15:31:54 +0530 | [diff] [blame] | 160 | assertThat(testReportMsg, is(reportMsg)); |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 161 | } |
| 162 | |
| 163 | /** |
| 164 | * This test case checks for SRP Object,LSP Object(symbolic path tlv),ERO Object,LSPA Object,BandWidth Object, |
| 165 | * Metric-list SRP Object,LSP Object(symbolic path tlv),ERO Object,LSPA Object,BandWidth Object,Metric-list, |
| 166 | * RRO Object |
| 167 | * in PcRpt message. |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 168 | */ |
| 169 | @Test |
Mahesh Poojary S | f1bbd36 | 2016-02-25 18:19:59 +0530 | [diff] [blame] | 170 | public void reportMessageTest42() throws PcepParseException, PcepOutOfBoundMessageException { |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 171 | |
| 172 | byte[] reportMsg = new byte[] {0x20, 0x0a, 0x00, (byte) 0xE8, |
| 173 | 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP object |
bharat saraswal | b4e5cbe | 2015-09-02 19:33:20 +0530 | [diff] [blame] | 174 | 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 175 | 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //symbolic path tlv |
| 176 | 0x07, 0x10, 0x00, 0x14, //ERO object |
bharat saraswal | b4e5cbe | 2015-09-02 19:33:20 +0530 | [diff] [blame] | 177 | 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00, |
| 178 | 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00, |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 179 | 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object |
| 180 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 181 | 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object |
| 182 | 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20, //Metric object |
| 183 | 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP object |
bharat saraswal | b4e5cbe | 2015-09-02 19:33:20 +0530 | [diff] [blame] | 184 | 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 185 | 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //symbolic path tlv |
| 186 | 0x07, 0x10, 0x00, 0x14, //ERO object |
Avantika-Huawei | 56c1184 | 2016-04-28 00:56:56 +0530 | [diff] [blame] | 187 | 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00, //ERO IPv4 subobjects |
bharat saraswal | b4e5cbe | 2015-09-02 19:33:20 +0530 | [diff] [blame] | 188 | 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00, |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 189 | 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object |
| 190 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 191 | 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object |
| 192 | 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20, //Metric object |
| 193 | 0x08, 0x10, 0x00, 0x34, 0x01, 0x08, 0x11, 0x01, //RRO object |
Avantika-Huawei | 56c1184 | 2016-04-28 00:56:56 +0530 | [diff] [blame] | 194 | 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, //RRO IPv4 subobjects |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 195 | 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x06, 0x06, |
| 196 | 0x06, 0x06, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01, |
| 197 | 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01, |
| 198 | 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x05, 0x05, 0x05, 0x05, 0x04, 0x00}; |
| 199 | |
| 200 | byte[] testReportMsg = {0}; |
| 201 | ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); |
| 202 | buffer.writeBytes(reportMsg); |
| 203 | |
| 204 | PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); |
| 205 | PcepMessage message = null; |
| 206 | |
| 207 | message = reader.readFrom(buffer); |
| 208 | |
Priyanka bhaskar | 3e1a697 | 2015-08-27 15:31:54 +0530 | [diff] [blame] | 209 | assertThat(message, instanceOf(PcepReportMsg.class)); |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 210 | ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); |
| 211 | message.writeTo(buf); |
| 212 | |
Priyanka bhaskar | 3e1a697 | 2015-08-27 15:31:54 +0530 | [diff] [blame] | 213 | int readLen = buf.writerIndex(); |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 214 | testReportMsg = new byte[readLen]; |
| 215 | buf.readBytes(testReportMsg, 0, readLen); |
| 216 | |
Priyanka bhaskar | 3e1a697 | 2015-08-27 15:31:54 +0530 | [diff] [blame] | 217 | assertThat(testReportMsg, is(reportMsg)); |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 218 | } |
Avantika-Huawei | 56c1184 | 2016-04-28 00:56:56 +0530 | [diff] [blame] | 219 | |
| 220 | /** |
| 221 | * Tests PCRpt msg with Path-Setup-Type TLV as SR. |
| 222 | * |
| 223 | * @throws PcepParseException |
| 224 | * @throws PcepOutOfBoundMessageException |
| 225 | */ |
| 226 | @Test |
| 227 | public void reportMessageTest43() throws PcepParseException, PcepOutOfBoundMessageException { |
| 228 | |
| 229 | byte[] reportMsg = new byte[] {0x20, 0x0a, 0x00, (byte) 0x3C, |
| 230 | 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP object |
| 231 | 0x00, 0x1c, 0x00, 0x04, // PATH-SETUP-TYPE TLV |
| 232 | 0x00, 0x00, 0x00, 0x01, |
| 233 | 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object |
| 234 | 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //symbolic path tlv |
| 235 | 0x07, 0x10, 0x00, 0x14, //ERO object |
| 236 | 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00, //ERO IPv4 subobjects |
| 237 | 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00, |
| 238 | }; |
| 239 | |
| 240 | byte[] testReportMsg = {0}; |
| 241 | ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); |
| 242 | buffer.writeBytes(reportMsg); |
| 243 | |
| 244 | PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); |
| 245 | PcepMessage message = null; |
| 246 | |
| 247 | message = reader.readFrom(buffer); |
| 248 | assertThat(message, instanceOf(PcepReportMsg.class)); |
| 249 | ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); |
| 250 | message.writeTo(buf); |
| 251 | |
| 252 | int readLen = buf.writerIndex(); |
| 253 | testReportMsg = new byte[readLen]; |
| 254 | buf.readBytes(testReportMsg, 0, readLen); |
| 255 | |
| 256 | assertThat(testReportMsg, is(reportMsg)); |
| 257 | } |
| 258 | |
| 259 | /** |
| 260 | * Tests PCRpt msg with Path-Setup-Type TLV as "without SR and without signalling". |
| 261 | * |
| 262 | * @throws PcepParseException |
| 263 | * @throws PcepOutOfBoundMessageException |
| 264 | */ |
| 265 | @Test |
| 266 | public void reportMessageTest44() throws PcepParseException, PcepOutOfBoundMessageException { |
| 267 | |
| 268 | byte[] reportMsg = new byte[] {0x20, 0x0a, 0x00, (byte) 0x3C, |
| 269 | 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP object |
| 270 | 0x00, 0x1c, 0x00, 0x04, // PATH-SETUP-TYPE TLV |
| 271 | 0x00, 0x00, 0x00, 0x02, |
| 272 | 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object |
| 273 | 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //symbolic path tlv |
| 274 | 0x07, 0x10, 0x00, 0x14, //ERO object |
| 275 | 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00, //ERO IPv4 subobjects |
| 276 | 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00, |
| 277 | }; |
| 278 | |
| 279 | byte[] testReportMsg = {0}; |
| 280 | ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); |
| 281 | buffer.writeBytes(reportMsg); |
| 282 | |
| 283 | PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); |
| 284 | PcepMessage message = null; |
| 285 | |
| 286 | message = reader.readFrom(buffer); |
| 287 | assertThat(message, instanceOf(PcepReportMsg.class)); |
| 288 | ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); |
| 289 | message.writeTo(buf); |
| 290 | |
| 291 | int readLen = buf.writerIndex(); |
| 292 | testReportMsg = new byte[readLen]; |
| 293 | buf.readBytes(testReportMsg, 0, readLen); |
| 294 | |
| 295 | assertThat(testReportMsg, is(reportMsg)); |
| 296 | } |
| 297 | |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 298 | } |