bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2014-2015 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 | */ |
| 16 | package org.onosproject.pcepio; |
| 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; |
| 21 | import org.onosproject.pcepio.exceptions.PcepParseException; |
| 22 | import org.onosproject.pcepio.protocol.PcepFactories; |
Mahesh Poojary | ea2e4df | 2015-08-27 20:38:16 +0530 | [diff] [blame] | 23 | import org.onosproject.pcepio.protocol.PcepLabelUpdateMsg; |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 24 | import org.onosproject.pcepio.protocol.PcepMessage; |
| 25 | import org.onosproject.pcepio.protocol.PcepMessageReader; |
Mahesh Poojary | ea2e4df | 2015-08-27 20:38:16 +0530 | [diff] [blame] | 26 | |
| 27 | import static org.hamcrest.MatcherAssert.assertThat; |
| 28 | import static org.hamcrest.Matchers.instanceOf; |
| 29 | import static org.hamcrest.Matchers.is; |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 30 | |
| 31 | public class PcepLabelUpdateMsgTest { |
| 32 | |
| 33 | /** |
| 34 | * This test case checks for |
| 35 | * <pce-label-download> SRP, LSP, LABEL Object. |
| 36 | * in PcepLabelUpdate message. |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 37 | */ |
| 38 | @Test |
| 39 | public void labelUpdateMessageTest1() throws PcepParseException { |
| 40 | |
Mahesh Poojary | ea2e4df | 2015-08-27 20:38:16 +0530 | [diff] [blame] | 41 | byte[] labelUpdate = new byte[]{0x20, 0x0D, 0x00, 0x24, // common header |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 42 | 0x21, 0x10, 0x00, 0x0C, // SRP Object Header |
| 43 | 0x00, 0x00, 0x00, 0x00, |
| 44 | 0x00, 0x00, 0x00, 0x10, |
| 45 | 0x20, 0x10, 0x00, 0x08, // LSP Object Header |
| 46 | 0x00, 0x01, 0x00, 0x00, |
| 47 | 0x23, 0x10, 0x00, 0x0C, // LABEL Object Header |
| 48 | 0x00, 0x00, 0x00, 0x00, |
| 49 | 0x00, 0x00, 0x00, 0x66}; |
| 50 | |
| 51 | ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); |
| 52 | buffer.writeBytes(labelUpdate); |
| 53 | |
| 54 | PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); |
| 55 | PcepMessage message = null; |
| 56 | |
| 57 | message = reader.readFrom(buffer); |
| 58 | |
| 59 | byte[] testLabelUpdateMsg = {0}; |
Mahesh Poojary | ea2e4df | 2015-08-27 20:38:16 +0530 | [diff] [blame] | 60 | assertThat(message, instanceOf(PcepLabelUpdateMsg.class)); |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 61 | |
Mahesh Poojary | ea2e4df | 2015-08-27 20:38:16 +0530 | [diff] [blame] | 62 | |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 63 | ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); |
| 64 | message.writeTo(buf); |
| 65 | |
Mahesh Poojary | ea2e4df | 2015-08-27 20:38:16 +0530 | [diff] [blame] | 66 | int readLen = buf.writerIndex(); |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 67 | testLabelUpdateMsg = new byte[readLen]; |
| 68 | buf.readBytes(testLabelUpdateMsg, 0, readLen); |
| 69 | |
Mahesh Poojary | ea2e4df | 2015-08-27 20:38:16 +0530 | [diff] [blame] | 70 | assertThat(testLabelUpdateMsg, is(labelUpdate)); |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 71 | } |
| 72 | |
| 73 | /** |
| 74 | * This test case checks for |
| 75 | * <pce-label-download> SRP, LSP, LABEL Object, LABEL Object. |
| 76 | * in PcepLabelUpdate message. |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 77 | */ |
| 78 | @Test |
| 79 | public void labelUpdateMessageTest2() throws PcepParseException { |
| 80 | |
Mahesh Poojary | ea2e4df | 2015-08-27 20:38:16 +0530 | [diff] [blame] | 81 | byte[] labelUpdate = new byte[]{0x20, 0x0D, 0x00, 0x30, // common header |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 82 | 0x21, 0x10, 0x00, 0x0C, // SRP Object Header |
| 83 | 0x00, 0x00, 0x00, 0x00, |
| 84 | 0x00, 0x00, 0x00, 0x10, |
| 85 | 0x20, 0x10, 0x00, 0x08, // LSP Object Header |
| 86 | 0x00, 0x01, 0x00, 0x00, |
| 87 | 0x23, 0x10, 0x00, 0x0C, // LABEL Object Header |
| 88 | 0x00, 0x00, 0x00, 0x00, |
| 89 | 0x00, 0x00, 0x00, 0x66, |
| 90 | 0x23, 0x10, 0x00, 0x0C, // LABEL Object Header |
| 91 | 0x00, 0x00, 0x00, 0x00, |
| 92 | 0x00, 0x00, 0x00, 0x77}; |
| 93 | |
| 94 | ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); |
| 95 | buffer.writeBytes(labelUpdate); |
| 96 | |
| 97 | PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); |
| 98 | PcepMessage message = null; |
| 99 | |
| 100 | message = reader.readFrom(buffer); |
| 101 | |
| 102 | byte[] testLabelUpdateMsg = {0}; |
Mahesh Poojary | ea2e4df | 2015-08-27 20:38:16 +0530 | [diff] [blame] | 103 | assertThat(message, instanceOf(PcepLabelUpdateMsg.class)); |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 104 | ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); |
| 105 | message.writeTo(buf); |
| 106 | |
Mahesh Poojary | ea2e4df | 2015-08-27 20:38:16 +0530 | [diff] [blame] | 107 | int readLen = buf.writerIndex(); |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 108 | testLabelUpdateMsg = new byte[readLen]; |
| 109 | buf.readBytes(testLabelUpdateMsg, 0, readLen); |
| 110 | |
Mahesh Poojary | ea2e4df | 2015-08-27 20:38:16 +0530 | [diff] [blame] | 111 | assertThat(testLabelUpdateMsg, is(labelUpdate)); |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 112 | } |
| 113 | |
| 114 | /** |
| 115 | * This test case checks for |
| 116 | * <pce-label-map> SRP, LABEL, FEC Object. |
| 117 | * in PcepLabelUpdate message. |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 118 | */ |
| 119 | @Test |
| 120 | public void labelUpdateMessageTest3() throws PcepParseException { |
| 121 | |
Mahesh Poojary | ea2e4df | 2015-08-27 20:38:16 +0530 | [diff] [blame] | 122 | byte[] labelUpdate = new byte[]{0x20, 0x0D, 0x00, 0x24, // common header |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 123 | 0x21, 0x10, 0x00, 0x0C, // SRP Object Header |
| 124 | 0x00, 0x00, 0x00, 0x00, |
| 125 | 0x00, 0x00, 0x00, 0x10, |
| 126 | 0x23, 0x10, 0x00, 0x0C, // LABEL Object Header |
| 127 | 0x00, 0x00, 0x00, 0x00, |
| 128 | 0x00, 0x00, 0x00, 0x66, |
| 129 | 0x24, 0x10, 0x00, 0x08, // FEC Object Header |
| 130 | 0x0A, 0x0A, 0x0B, 0x0B}; |
| 131 | |
| 132 | ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); |
| 133 | buffer.writeBytes(labelUpdate); |
| 134 | |
| 135 | PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); |
| 136 | PcepMessage message = null; |
| 137 | |
| 138 | message = reader.readFrom(buffer); |
| 139 | |
| 140 | byte[] testLabelUpdateMsg = {0}; |
Mahesh Poojary | ea2e4df | 2015-08-27 20:38:16 +0530 | [diff] [blame] | 141 | assertThat(message, instanceOf(PcepLabelUpdateMsg.class)); |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 142 | ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); |
| 143 | message.writeTo(buf); |
| 144 | |
Mahesh Poojary | ea2e4df | 2015-08-27 20:38:16 +0530 | [diff] [blame] | 145 | int readLen = buf.writerIndex(); |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 146 | testLabelUpdateMsg = new byte[readLen]; |
| 147 | buf.readBytes(testLabelUpdateMsg, 0, readLen); |
| 148 | |
Mahesh Poojary | ea2e4df | 2015-08-27 20:38:16 +0530 | [diff] [blame] | 149 | assertThat(testLabelUpdateMsg, is(labelUpdate)); |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 150 | } |
| 151 | |
| 152 | /** |
| 153 | * This test case checks for |
| 154 | * <pce-label-download> SRP, LSP, LABEL, LABEL, <pce-label-download> SRP, LSP, LABEL |
| 155 | * in PcepLabelUpdate message. |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 156 | */ |
| 157 | @Test |
| 158 | public void labelUpdateMessageTest4() throws PcepParseException { |
| 159 | |
Mahesh Poojary | ea2e4df | 2015-08-27 20:38:16 +0530 | [diff] [blame] | 160 | byte[] labelUpdate = new byte[]{0x20, 0x0D, 0x00, 0x50, // common header |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 161 | 0x21, 0x10, 0x00, 0x0C, // SRP Object Header |
| 162 | 0x00, 0x00, 0x00, 0x00, |
| 163 | 0x00, 0x00, 0x00, 0x10, |
| 164 | 0x20, 0x10, 0x00, 0x08, // LSP Object Header |
| 165 | 0x00, 0x01, 0x00, 0x00, |
| 166 | 0x23, 0x10, 0x00, 0x0C, // LABEL Object Header |
| 167 | 0x00, 0x00, 0x00, 0x00, |
| 168 | 0x00, 0x00, 0x00, 0x66, |
| 169 | 0x23, 0x10, 0x00, 0x0C, // LABEL Object Header |
| 170 | 0x00, 0x00, 0x00, 0x00, |
| 171 | 0x00, 0x00, 0x00, 0x77, |
| 172 | 0x21, 0x10, 0x00, 0x0C, // SRP Object Header |
| 173 | 0x00, 0x00, 0x00, 0x00, |
| 174 | 0x00, 0x00, 0x00, 0x11, |
| 175 | 0x20, 0x10, 0x00, 0x08, // LSP Object Header |
| 176 | 0x00, 0x02, 0x00, 0x00, |
| 177 | 0x23, 0x10, 0x00, 0x0C, // LABEL Object Header |
| 178 | 0x00, 0x00, 0x00, 0x00, |
| 179 | 0x00, 0x00, 0x00, 0x44}; |
| 180 | |
| 181 | ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); |
| 182 | buffer.writeBytes(labelUpdate); |
| 183 | |
| 184 | PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); |
| 185 | PcepMessage message = null; |
| 186 | |
| 187 | message = reader.readFrom(buffer); |
| 188 | |
| 189 | byte[] testLabelUpdateMsg = {0}; |
Mahesh Poojary | ea2e4df | 2015-08-27 20:38:16 +0530 | [diff] [blame] | 190 | assertThat(message, instanceOf(PcepLabelUpdateMsg.class)); |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 191 | ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); |
| 192 | message.writeTo(buf); |
| 193 | |
Mahesh Poojary | ea2e4df | 2015-08-27 20:38:16 +0530 | [diff] [blame] | 194 | int readLen = buf.writerIndex(); |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 195 | testLabelUpdateMsg = new byte[readLen]; |
| 196 | buf.readBytes(testLabelUpdateMsg, 0, readLen); |
| 197 | |
Mahesh Poojary | ea2e4df | 2015-08-27 20:38:16 +0530 | [diff] [blame] | 198 | assertThat(testLabelUpdateMsg, is(labelUpdate)); |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 199 | } |
| 200 | |
| 201 | /** |
| 202 | * This test case checks for |
| 203 | * <pce-label-map> SRP, LABEL, FEC, <pce-label-map> SRP, LABEL, FEC. |
| 204 | * in PcepLabelUpdate message. |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 205 | */ |
| 206 | @Test |
| 207 | public void labelUpdateMessageTest5() throws PcepParseException { |
| 208 | |
Mahesh Poojary | ea2e4df | 2015-08-27 20:38:16 +0530 | [diff] [blame] | 209 | byte[] labelUpdate = new byte[]{0x20, 0x0D, 0x00, 0x44, // common header |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 210 | 0x21, 0x10, 0x00, 0x0C, // SRP Object Header |
| 211 | 0x00, 0x00, 0x00, 0x00, |
| 212 | 0x00, 0x00, 0x00, 0x10, |
| 213 | 0x23, 0x10, 0x00, 0x0C, // LABEL Object Header |
| 214 | 0x00, 0x00, 0x00, 0x01, |
| 215 | 0x00, 0x00, 0x00, 0x66, |
| 216 | 0x24, 0x10, 0x00, 0x08, // FEC Object Header |
| 217 | 0x0A, 0x0A, 0x0B, 0x0B, |
| 218 | 0x21, 0x10, 0x00, 0x0C, // SRP Object Header |
| 219 | 0x00, 0x00, 0x00, 0x00, |
| 220 | 0x00, 0x00, 0x00, 0x11, |
| 221 | 0x23, 0x10, 0x00, 0x0C, // LABEL Object Header |
| 222 | 0x00, 0x00, 0x00, 0x00, |
| 223 | 0x00, 0x00, 0x00, 0x66, |
| 224 | 0x24, 0x10, 0x00, 0x08, // FEC Object Header |
| 225 | 0x0A, 0x0A, 0x0C, 0x0C}; |
| 226 | |
| 227 | ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); |
| 228 | buffer.writeBytes(labelUpdate); |
| 229 | |
| 230 | PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); |
| 231 | PcepMessage message = null; |
| 232 | |
| 233 | message = reader.readFrom(buffer); |
| 234 | |
| 235 | byte[] testLabelUpdateMsg = {0}; |
Mahesh Poojary | ea2e4df | 2015-08-27 20:38:16 +0530 | [diff] [blame] | 236 | assertThat(message, instanceOf(PcepLabelUpdateMsg.class)); |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 237 | ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); |
| 238 | message.writeTo(buf); |
| 239 | |
Mahesh Poojary | ea2e4df | 2015-08-27 20:38:16 +0530 | [diff] [blame] | 240 | int readLen = buf.writerIndex(); |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 241 | testLabelUpdateMsg = new byte[readLen]; |
| 242 | buf.readBytes(testLabelUpdateMsg, 0, readLen); |
| 243 | |
Mahesh Poojary | ea2e4df | 2015-08-27 20:38:16 +0530 | [diff] [blame] | 244 | assertThat(testLabelUpdateMsg, is(labelUpdate)); |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 245 | } |
| 246 | |
| 247 | /** |
| 248 | * This test case checks for |
| 249 | * <pce-label-download> SRP, LSP, LABEL, LABEL, <pce-label-download> SRP, LABEL, FEC. |
| 250 | * in PcepLabelUpdate message. |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 251 | */ |
| 252 | @Test |
| 253 | public void labelUpdateMessageTest6() throws PcepParseException { |
| 254 | |
Mahesh Poojary | ea2e4df | 2015-08-27 20:38:16 +0530 | [diff] [blame] | 255 | byte[] labelUpdate = new byte[]{0x20, 0x0D, 0x00, 0x50, // common header |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 256 | 0x21, 0x10, 0x00, 0x0C, // SRP Object Header |
| 257 | 0x00, 0x00, 0x00, 0x00, |
| 258 | 0x00, 0x00, 0x00, 0x10, |
| 259 | 0x20, 0x10, 0x00, 0x08, // LSP Object Header |
| 260 | 0x00, 0x01, 0x00, 0x00, |
| 261 | 0x23, 0x10, 0x00, 0x0C, // LABEL Object Header |
| 262 | 0x00, 0x00, 0x00, 0x00, |
| 263 | 0x00, 0x00, 0x00, 0x66, |
| 264 | 0x23, 0x10, 0x00, 0x0C, // LABEL Object Header |
| 265 | 0x00, 0x00, 0x00, 0x00, |
| 266 | 0x00, 0x00, 0x00, 0x77, |
| 267 | 0x21, 0x10, 0x00, 0x0C, // SRP Object Header |
| 268 | 0x00, 0x00, 0x00, 0x00, |
| 269 | 0x00, 0x00, 0x00, 0x12, |
| 270 | 0x23, 0x10, 0x00, 0x0C, // LABEL Object Header |
| 271 | 0x00, 0x00, 0x00, 0x00, |
| 272 | 0x00, 0x00, 0x00, 0x66, |
| 273 | 0x24, 0x10, 0x00, 0x08, // FEC Object Header |
| 274 | 0x0A, 0x0A, 0x0D, 0x0D}; |
| 275 | |
| 276 | ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); |
| 277 | buffer.writeBytes(labelUpdate); |
| 278 | |
| 279 | PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); |
| 280 | PcepMessage message = null; |
| 281 | |
| 282 | message = reader.readFrom(buffer); |
| 283 | |
| 284 | byte[] testLabelUpdateMsg = {0}; |
Mahesh Poojary | ea2e4df | 2015-08-27 20:38:16 +0530 | [diff] [blame] | 285 | assertThat(message, instanceOf(PcepLabelUpdateMsg.class)); |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 286 | ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); |
| 287 | message.writeTo(buf); |
| 288 | |
Mahesh Poojary | ea2e4df | 2015-08-27 20:38:16 +0530 | [diff] [blame] | 289 | int readLen = buf.writerIndex(); |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 290 | testLabelUpdateMsg = new byte[readLen]; |
| 291 | buf.readBytes(testLabelUpdateMsg, 0, readLen); |
| 292 | |
Mahesh Poojary | ea2e4df | 2015-08-27 20:38:16 +0530 | [diff] [blame] | 293 | assertThat(testLabelUpdateMsg, is(labelUpdate)); |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 294 | } |
| 295 | |
| 296 | /** |
| 297 | * This test case checks for |
Mahesh Poojary | ea2e4df | 2015-08-27 20:38:16 +0530 | [diff] [blame] | 298 | * <pce-label-download> SRP, LABEL, FEC, <pce-label-download> SRP, LSP, LABEL, LABEL. |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 299 | * in PcepLabelUpdate message. |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 300 | */ |
| 301 | @Test |
| 302 | public void labelUpdateMessageTest7() throws PcepParseException { |
| 303 | |
Mahesh Poojary | ea2e4df | 2015-08-27 20:38:16 +0530 | [diff] [blame] | 304 | byte[] labelUpdate = new byte[]{0x20, 0x0D, 0x00, 0x50, // common header |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 305 | 0x21, 0x10, 0x00, 0x0C, // SRP Object Header |
| 306 | 0x00, 0x00, 0x00, 0x00, |
| 307 | 0x00, 0x00, 0x00, 0x12, |
| 308 | 0x23, 0x10, 0x00, 0x0C, // LABEL Object Header |
| 309 | 0x00, 0x00, 0x00, 0x00, |
| 310 | 0x00, 0x00, 0x00, 0x66, |
| 311 | 0x24, 0x10, 0x00, 0x08, // FEC Object Header |
| 312 | 0x0A, 0x0A, 0x0D, 0x0D, |
| 313 | 0x21, 0x10, 0x00, 0x0C, // SRP Object Header |
| 314 | 0x00, 0x00, 0x00, 0x00, |
| 315 | 0x00, 0x00, 0x00, 0x10, |
| 316 | 0x20, 0x10, 0x00, 0x08, // LSP Object Header |
| 317 | 0x00, 0x01, 0x00, 0x00, |
| 318 | 0x23, 0x10, 0x00, 0x0C, // LABEL Object Header |
| 319 | 0x00, 0x00, 0x00, 0x00, |
| 320 | 0x00, 0x00, 0x00, 0x66, |
| 321 | 0x23, 0x10, 0x00, 0x0C, // LABEL Object Header |
| 322 | 0x00, 0x00, 0x00, 0x00, |
| 323 | 0x00, 0x00, 0x00, 0x77}; |
| 324 | |
| 325 | ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); |
| 326 | buffer.writeBytes(labelUpdate); |
| 327 | |
| 328 | PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); |
| 329 | PcepMessage message = null; |
| 330 | |
| 331 | message = reader.readFrom(buffer); |
| 332 | |
| 333 | byte[] testLabelUpdateMsg = {0}; |
Mahesh Poojary | ea2e4df | 2015-08-27 20:38:16 +0530 | [diff] [blame] | 334 | assertThat(message, instanceOf(PcepLabelUpdateMsg.class)); |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 335 | ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); |
| 336 | message.writeTo(buf); |
| 337 | |
Mahesh Poojary | ea2e4df | 2015-08-27 20:38:16 +0530 | [diff] [blame] | 338 | int readLen = buf.writerIndex(); |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 339 | testLabelUpdateMsg = new byte[readLen]; |
| 340 | buf.readBytes(testLabelUpdateMsg, 0, readLen); |
| 341 | |
Mahesh Poojary | ea2e4df | 2015-08-27 20:38:16 +0530 | [diff] [blame] | 342 | assertThat(testLabelUpdateMsg, is(labelUpdate)); |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 343 | } |
| 344 | |
| 345 | /** |
| 346 | * This test case checks for |
| 347 | * <pce-label-download> SRP, LABEL, FEC, <pce-label-download> SRP, LSP, LABEL, LABEL. |
| 348 | * <pce-label-download> SRP, LSP, LABEL, LABEL. |
| 349 | * in PcepLabelUpdate message. |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 350 | */ |
| 351 | @Test |
| 352 | public void labelUpdateMessageTest8() throws PcepParseException { |
| 353 | |
Mahesh Poojary | ea2e4df | 2015-08-27 20:38:16 +0530 | [diff] [blame] | 354 | byte[] labelUpdate = new byte[]{0x20, 0x0D, 0x00, 0x7C, // common header |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 355 | 0x21, 0x10, 0x00, 0x0C, // SRP Object Header |
| 356 | 0x00, 0x00, 0x00, 0x00, |
| 357 | 0x00, 0x00, 0x00, 0x12, |
| 358 | 0x23, 0x10, 0x00, 0x0C, // LABEL Object Header |
| 359 | 0x00, 0x00, 0x00, 0x00, |
| 360 | 0x00, 0x00, 0x00, 0x66, |
| 361 | 0x24, 0x10, 0x00, 0x08, // FEC Object Header |
| 362 | 0x0A, 0x0A, 0x0D, 0x0D, |
| 363 | 0x21, 0x10, 0x00, 0x0C, // SRP Object Header |
| 364 | 0x00, 0x00, 0x00, 0x00, |
| 365 | 0x00, 0x00, 0x00, 0x10, |
| 366 | 0x20, 0x10, 0x00, 0x08, // LSP Object Header |
| 367 | 0x00, 0x01, 0x00, 0x00, |
| 368 | 0x23, 0x10, 0x00, 0x0C, // LABEL Object Header |
| 369 | 0x00, 0x00, 0x00, 0x00, |
| 370 | 0x00, 0x00, 0x00, 0x66, |
| 371 | 0x23, 0x10, 0x00, 0x0C, // LABEL Object Header |
| 372 | 0x00, 0x00, 0x00, 0x00, |
| 373 | 0x00, 0x00, 0x00, 0x77, |
| 374 | 0x21, 0x10, 0x00, 0x0C, // SRP Object Header |
| 375 | 0x00, 0x00, 0x00, 0x00, |
| 376 | 0x00, 0x00, 0x00, 0x10, |
| 377 | 0x20, 0x10, 0x00, 0x08, // LSP Object Header |
| 378 | 0x00, 0x01, 0x00, 0x00, |
| 379 | 0x23, 0x10, 0x00, 0x0C, // LABEL Object Header |
| 380 | 0x00, 0x00, 0x00, 0x00, |
| 381 | 0x00, 0x00, 0x00, 0x66, |
| 382 | 0x23, 0x10, 0x00, 0x0C, // LABEL Object Header |
| 383 | 0x00, 0x00, 0x00, 0x00, |
| 384 | 0x00, 0x00, 0x00, 0x77}; |
| 385 | |
| 386 | ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); |
| 387 | buffer.writeBytes(labelUpdate); |
| 388 | |
| 389 | PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); |
| 390 | PcepMessage message = null; |
| 391 | |
| 392 | message = reader.readFrom(buffer); |
| 393 | |
| 394 | byte[] testLabelUpdateMsg = {0}; |
| 395 | |
Mahesh Poojary | ea2e4df | 2015-08-27 20:38:16 +0530 | [diff] [blame] | 396 | assertThat(message, instanceOf(PcepLabelUpdateMsg.class)); |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 397 | ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); |
| 398 | message.writeTo(buf); |
| 399 | |
Mahesh Poojary | ea2e4df | 2015-08-27 20:38:16 +0530 | [diff] [blame] | 400 | int readLen = buf.writerIndex(); |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 401 | testLabelUpdateMsg = new byte[readLen]; |
| 402 | buf.readBytes(testLabelUpdateMsg, 0, readLen); |
| 403 | |
Mahesh Poojary | ea2e4df | 2015-08-27 20:38:16 +0530 | [diff] [blame] | 404 | assertThat(testLabelUpdateMsg, is(labelUpdate)); |
bharat saraswal | e2e7a00 | 2015-08-21 22:47:30 +0530 | [diff] [blame] | 405 | } |
| 406 | } |