bharat saraswal | f7364db | 2015-08-11 13:39:31 +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 java.util.Arrays; |
| 19 | |
| 20 | import org.jboss.netty.buffer.ChannelBuffer; |
| 21 | import org.jboss.netty.buffer.ChannelBuffers; |
| 22 | import org.junit.After; |
| 23 | import org.junit.Assert; |
| 24 | import org.junit.Before; |
| 25 | import org.junit.Test; |
| 26 | import org.onosproject.pcepio.exceptions.PcepParseException; |
| 27 | import org.onosproject.pcepio.protocol.PcepFactories; |
| 28 | import org.onosproject.pcepio.protocol.PcepInitiateMsg; |
| 29 | import org.onosproject.pcepio.protocol.PcepMessage; |
| 30 | import org.onosproject.pcepio.protocol.PcepMessageReader; |
| 31 | import org.slf4j.Logger; |
| 32 | import org.slf4j.LoggerFactory; |
| 33 | |
| 34 | public class PcepInitiateMsgTest { |
| 35 | |
| 36 | protected static final Logger log = LoggerFactory.getLogger(PcepInitiateMsgTest.class); |
| 37 | |
| 38 | @Before |
| 39 | public void startUp() { |
| 40 | |
| 41 | } |
| 42 | |
| 43 | @After |
| 44 | public void tearDown() { |
| 45 | |
| 46 | } |
| 47 | |
| 48 | @Test |
| 49 | public void initiateMessageTest1() throws PcepParseException { |
| 50 | |
| 51 | /* srp, lsp, end-point, ERO. |
| 52 | */ |
| 53 | byte[] initiateCreationMsg = new byte[] {0x20, 0x0C, 0x00, 0x54, |
| 54 | 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP object |
| 55 | 0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x00, 0x08, //LSP object |
| 56 | 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv |
| 57 | 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, |
| 58 | 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0x02, 0x02, |
| 59 | 0x00, 0x11, 0x00, 0x04, 0x54, 0x31, 0x32, 0x33, //SymbolicPathTlv |
| 60 | 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object |
| 61 | 0x07, 0x10, 0x00, 0x14, //ERO object |
| 62 | 0x01, 0x08, 0x0C, 0x01, 0x01, 0x01, 0x00, 0x00, |
| 63 | 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00}; |
| 64 | |
| 65 | byte[] testInitiateCreationMsg = {0}; |
| 66 | ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); |
| 67 | buffer.writeBytes(initiateCreationMsg); |
| 68 | |
| 69 | PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); |
| 70 | PcepMessage message = null; |
| 71 | try { |
| 72 | message = reader.readFrom(buffer); |
| 73 | } catch (PcepParseException e) { |
| 74 | e.printStackTrace(); |
| 75 | } |
| 76 | |
| 77 | if (message instanceof PcepInitiateMsg) { |
| 78 | ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); |
| 79 | message.writeTo(buf); |
| 80 | testInitiateCreationMsg = buf.array(); |
| 81 | |
| 82 | int iReadLen = buf.writerIndex() - 0; |
| 83 | testInitiateCreationMsg = new byte[iReadLen]; |
| 84 | buf.readBytes(testInitiateCreationMsg, 0, iReadLen); |
| 85 | |
| 86 | if (Arrays.equals(initiateCreationMsg, testInitiateCreationMsg)) { |
| 87 | Assert.assertArrayEquals(initiateCreationMsg, testInitiateCreationMsg); |
| 88 | log.debug("PCInitiate Msg are equal :" + initiateCreationMsg); |
| 89 | } else { |
| 90 | Assert.fail("test case failed"); |
| 91 | log.debug("not equal"); |
| 92 | } |
| 93 | } else { |
| 94 | Assert.fail("test case failed"); |
| 95 | log.debug("not equal"); |
| 96 | } |
| 97 | } |
| 98 | |
| 99 | @Test |
| 100 | public void initiateMessageTest2() throws PcepParseException { |
| 101 | /* srp, lsp. |
| 102 | */ |
| 103 | byte[] initiateDeletionMsg = new byte[] {0x20, 0x0C, 0x00, 0x34, |
| 104 | 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, //SRP object |
| 105 | 0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x20, 0x10, //LSP object |
| 106 | 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv |
| 107 | 0x01, 0x01, 0x01, 0x01, 0x00, 0x43, (byte) 0x83, 0x01, |
| 108 | 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, |
| 109 | 0x00, 0x11, 0x00, 0x04, 0x54, 0x31, 0x32, 0x33 }; //SymbolicPathTlv |
| 110 | |
| 111 | byte[] testInitiateDeletionMsg = {0}; |
| 112 | ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); |
| 113 | buffer.writeBytes(initiateDeletionMsg); |
| 114 | |
| 115 | PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); |
| 116 | PcepMessage message = null; |
| 117 | try { |
| 118 | message = reader.readFrom(buffer); |
| 119 | } catch (PcepParseException e) { |
| 120 | e.printStackTrace(); |
| 121 | } |
| 122 | |
| 123 | if (message instanceof PcepInitiateMsg) { |
| 124 | ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); |
| 125 | message.writeTo(buf); |
| 126 | testInitiateDeletionMsg = buf.array(); |
| 127 | |
| 128 | int iReadLen = buf.writerIndex() - 0; |
| 129 | testInitiateDeletionMsg = new byte[iReadLen]; |
| 130 | buf.readBytes(testInitiateDeletionMsg, 0, iReadLen); |
| 131 | |
| 132 | if (Arrays.equals(initiateDeletionMsg, testInitiateDeletionMsg)) { |
| 133 | Assert.assertArrayEquals(initiateDeletionMsg, testInitiateDeletionMsg); |
| 134 | log.debug("PCInitiate Msg are equal :" + initiateDeletionMsg); |
| 135 | } else { |
| 136 | Assert.fail("test case failed"); |
| 137 | log.debug("not equal"); |
| 138 | } |
| 139 | } else { |
| 140 | Assert.fail("test case failed"); |
| 141 | log.debug("not equal"); |
| 142 | } |
| 143 | } |
| 144 | |
| 145 | @Test |
| 146 | public void initiateMessageTest3() throws PcepParseException { |
| 147 | |
| 148 | /* SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv, |
| 149 | * StatefulLspErrorCodeTlv, StatefulRsvpErrorSpecTlv), END-POINTS, ERO. |
| 150 | */ |
| 151 | byte[] initiateCreationMsg = new byte[] {0x20, 0x0C, 0x00, (byte) 0x64, |
| 152 | 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object |
| 153 | 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv |
| 154 | 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object |
| 155 | 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv |
| 156 | (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, |
| 157 | (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, |
| 158 | 0x00, 0x11, 0x00, 0x04, 0x54, 0x31, 0x32, 0x33, //SymbolicPathNameTlv |
| 159 | 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv |
| 160 | 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object |
| 161 | 0x07, 0x10, 0x00, 0x14, //ERO object |
| 162 | 0x01, 0x08, 0x0C, 0x01, 0x01, 0x01, 0x00, 0x00, |
| 163 | 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00}; |
| 164 | |
| 165 | byte[] testInitiateCreationMsg = {0}; |
| 166 | ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); |
| 167 | buffer.writeBytes(initiateCreationMsg); |
| 168 | |
| 169 | PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); |
| 170 | PcepMessage message = null; |
| 171 | try { |
| 172 | message = reader.readFrom(buffer); |
| 173 | } catch (PcepParseException e) { |
| 174 | e.printStackTrace(); |
| 175 | } |
| 176 | |
| 177 | if (message instanceof PcepInitiateMsg) { |
| 178 | ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); |
| 179 | message.writeTo(buf); |
| 180 | testInitiateCreationMsg = buf.array(); |
| 181 | |
| 182 | int iReadLen = buf.writerIndex() - 0; |
| 183 | testInitiateCreationMsg = new byte[iReadLen]; |
| 184 | buf.readBytes(testInitiateCreationMsg, 0, iReadLen); |
| 185 | |
| 186 | if (Arrays.equals(initiateCreationMsg, testInitiateCreationMsg)) { |
| 187 | Assert.assertArrayEquals(initiateCreationMsg, testInitiateCreationMsg); |
| 188 | log.debug("PCInitiate Msg are equal :" + initiateCreationMsg); |
| 189 | } else { |
| 190 | Assert.fail("test case failed"); |
| 191 | log.debug("not equal"); |
| 192 | } |
| 193 | } else { |
| 194 | Assert.fail("test case failed"); |
| 195 | log.debug("not equal"); |
| 196 | } |
| 197 | } |
| 198 | |
| 199 | @Test |
| 200 | public void initiateMessageTest4() throws PcepParseException { |
| 201 | |
| 202 | /* SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv, |
| 203 | * StatefulLspErrorCodeTlv), END-POINT, ERO. |
| 204 | */ |
| 205 | byte[] initiateCreationMsg = new byte[] {0x20, 0x0C, 0x00, (byte) 0x64, |
| 206 | 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object |
| 207 | 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv |
| 208 | 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object |
| 209 | 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv |
| 210 | (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, |
| 211 | (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, |
| 212 | 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv |
| 213 | 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv |
| 214 | 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object |
| 215 | 0x07, 0x10, 0x00, 0x14, //ERO object |
| 216 | 0x01, 0x08, 0x0C, 0x01, 0x01, 0x01, 0x00, 0x00, |
| 217 | 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00}; |
| 218 | |
| 219 | byte[] testInitiateCreationMsg = {0}; |
| 220 | ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); |
| 221 | buffer.writeBytes(initiateCreationMsg); |
| 222 | |
| 223 | PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); |
| 224 | PcepMessage message = null; |
| 225 | try { |
| 226 | message = reader.readFrom(buffer); |
| 227 | } catch (PcepParseException e) { |
| 228 | e.printStackTrace(); |
| 229 | } |
| 230 | |
| 231 | if (message instanceof PcepInitiateMsg) { |
| 232 | ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); |
| 233 | message.writeTo(buf); |
| 234 | testInitiateCreationMsg = buf.array(); |
| 235 | |
| 236 | int iReadLen = buf.writerIndex() - 0; |
| 237 | testInitiateCreationMsg = new byte[iReadLen]; |
| 238 | buf.readBytes(testInitiateCreationMsg, 0, iReadLen); |
| 239 | |
| 240 | if (Arrays.equals(initiateCreationMsg, testInitiateCreationMsg)) { |
| 241 | Assert.assertArrayEquals(initiateCreationMsg, testInitiateCreationMsg); |
| 242 | log.debug("PCInitiate Msg are equal :" + initiateCreationMsg); |
| 243 | } else { |
| 244 | Assert.fail("test case failed"); |
| 245 | log.debug("not equal"); |
| 246 | } |
| 247 | } else { |
| 248 | Assert.fail("test case failed"); |
| 249 | log.debug("not equal"); |
| 250 | } |
| 251 | } |
| 252 | |
| 253 | @Test |
| 254 | public void initiateMessageTest5() throws PcepParseException { |
| 255 | |
| 256 | /* SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv), |
| 257 | * END-POINT, ERO. |
| 258 | */ |
| 259 | byte[] initiateCreationMsg = new byte[] {0x20, 0x0C, 0x00, (byte) 0x5c, |
| 260 | 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object |
| 261 | 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv |
| 262 | 0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x10, 0x03, //LSP object |
| 263 | 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv |
| 264 | (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, |
| 265 | (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, |
| 266 | 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv |
| 267 | 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object |
| 268 | 0x07, 0x10, 0x00, 0x14, //ERO object |
| 269 | 0x01, 0x08, 0x0C, 0x01, 0x01, 0x01, 0x00, 0x00, |
| 270 | 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00 }; |
| 271 | |
| 272 | byte[] testInitiateCreationMsg = {0}; |
| 273 | ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); |
| 274 | buffer.writeBytes(initiateCreationMsg); |
| 275 | |
| 276 | PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); |
| 277 | PcepMessage message = null; |
| 278 | try { |
| 279 | message = reader.readFrom(buffer); |
| 280 | } catch (PcepParseException e) { |
| 281 | e.printStackTrace(); |
| 282 | } |
| 283 | |
| 284 | if (message instanceof PcepInitiateMsg) { |
| 285 | ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); |
| 286 | message.writeTo(buf); |
| 287 | testInitiateCreationMsg = buf.array(); |
| 288 | |
| 289 | int iReadLen = buf.writerIndex() - 0; |
| 290 | testInitiateCreationMsg = new byte[iReadLen]; |
| 291 | buf.readBytes(testInitiateCreationMsg, 0, iReadLen); |
| 292 | |
| 293 | if (Arrays.equals(initiateCreationMsg, testInitiateCreationMsg)) { |
| 294 | Assert.assertArrayEquals(initiateCreationMsg, testInitiateCreationMsg); |
| 295 | log.debug("PCInitiate Msg are equal :" + initiateCreationMsg); |
| 296 | } else { |
| 297 | Assert.fail("test case failed"); |
| 298 | log.debug("not equal"); |
| 299 | } |
| 300 | } else { |
| 301 | Assert.fail("test case failed"); |
| 302 | log.debug("not equal"); |
| 303 | } |
| 304 | } |
| 305 | |
| 306 | @Test |
| 307 | public void initiateMessageTest6() throws PcepParseException { |
| 308 | |
| 309 | /* SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv), |
| 310 | * END-POINT, ERO. |
| 311 | */ |
| 312 | byte[] initiateCreationMsg = new byte[] {0x20, 0x0C, 0x00, (byte) 0x5c, |
| 313 | 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, |
| 314 | 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv |
| 315 | 0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x10, 0x03, |
| 316 | 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv |
| 317 | (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, |
| 318 | (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, |
| 319 | 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv |
| 320 | 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object |
| 321 | 0x07, 0x10, 0x00, 0x14, //ERO object |
| 322 | 0x01, 0x08, 0x0C, 0x01, 0x01, 0x01, 0x00, 0x00, |
| 323 | 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00 }; |
| 324 | |
| 325 | byte[] testInitiateCreationMsg = {0}; |
| 326 | ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); |
| 327 | buffer.writeBytes(initiateCreationMsg); |
| 328 | |
| 329 | PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); |
| 330 | PcepMessage message = null; |
| 331 | try { |
| 332 | message = reader.readFrom(buffer); |
| 333 | } catch (PcepParseException e) { |
| 334 | e.printStackTrace(); |
| 335 | } |
| 336 | |
| 337 | if (message instanceof PcepInitiateMsg) { |
| 338 | ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); |
| 339 | message.writeTo(buf); |
| 340 | testInitiateCreationMsg = buf.array(); |
| 341 | |
| 342 | int iReadLen = buf.writerIndex() - 0; |
| 343 | testInitiateCreationMsg = new byte[iReadLen]; |
| 344 | buf.readBytes(testInitiateCreationMsg, 0, iReadLen); |
| 345 | |
| 346 | if (Arrays.equals(initiateCreationMsg, testInitiateCreationMsg)) { |
| 347 | Assert.assertArrayEquals(initiateCreationMsg, testInitiateCreationMsg); |
| 348 | log.debug("PCInitiate Msg are equal :" + initiateCreationMsg); |
| 349 | } else { |
| 350 | Assert.fail("test case failed"); |
| 351 | log.debug("not equal"); |
| 352 | } |
| 353 | } else { |
| 354 | Assert.fail("test case failed"); |
| 355 | log.debug("not equal"); |
| 356 | } |
| 357 | } |
| 358 | |
| 359 | @Test |
| 360 | public void initiateMessageTest7() throws PcepParseException { |
| 361 | |
| 362 | /* SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv), |
| 363 | * END-POINT, ERO. |
| 364 | */ |
| 365 | byte[] initiateCreationMsg = new byte[] {0x20, 0x0C, 0x00, (byte) 0x54, |
| 366 | 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, |
| 367 | 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv |
| 368 | 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object |
| 369 | 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv |
| 370 | (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, |
| 371 | (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, |
| 372 | 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object |
| 373 | 0x07, 0x10, 0x00, 0x14, //ERO object |
| 374 | 0x01, 0x08, 0x0C, 0x01, 0x01, 0x01, 0x00, 0x00, |
| 375 | 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00}; |
| 376 | |
| 377 | byte[] testInitiateCreationMsg = {0}; |
| 378 | ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); |
| 379 | buffer.writeBytes(initiateCreationMsg); |
| 380 | |
| 381 | PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); |
| 382 | PcepMessage message = null; |
| 383 | try { |
| 384 | message = reader.readFrom(buffer); |
| 385 | } catch (PcepParseException e) { |
| 386 | e.printStackTrace(); |
| 387 | } |
| 388 | |
| 389 | if (message instanceof PcepInitiateMsg) { |
| 390 | ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); |
| 391 | message.writeTo(buf); |
| 392 | testInitiateCreationMsg = buf.array(); |
| 393 | |
| 394 | int iReadLen = buf.writerIndex() - 0; |
| 395 | testInitiateCreationMsg = new byte[iReadLen]; |
| 396 | buf.readBytes(testInitiateCreationMsg, 0, iReadLen); |
| 397 | |
| 398 | if (Arrays.equals(initiateCreationMsg, testInitiateCreationMsg)) { |
| 399 | Assert.assertArrayEquals(initiateCreationMsg, testInitiateCreationMsg); |
| 400 | log.debug("PCInitiate Msg are equal :" + initiateCreationMsg); |
| 401 | } else { |
| 402 | Assert.fail("test case failed"); |
| 403 | log.debug("not equal"); |
| 404 | } |
| 405 | } else { |
| 406 | Assert.fail("test case failed"); |
| 407 | log.debug("not equal"); |
| 408 | } |
| 409 | } |
| 410 | |
| 411 | @Test |
| 412 | public void initiateMessageTest8() throws PcepParseException { |
| 413 | |
| 414 | /* SRP, LSP (StatefulIPv4LspIdentidiersTlv), |
| 415 | * END-POINT, ERO. |
| 416 | */ |
| 417 | byte[] initiateCreationMsg = new byte[] {0x20, 0x0C, 0x00, (byte) 0x4c, |
| 418 | 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object |
| 419 | 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object |
| 420 | 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv |
| 421 | (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, |
| 422 | (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, |
| 423 | 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object |
| 424 | 0x07, 0x10, 0x00, 0x14, //ERO object |
| 425 | 0x01, 0x08, 0x0C, 0x01, 0x01, 0x01, 0x00, 0x00, |
| 426 | 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00}; |
| 427 | |
| 428 | byte[] testInitiateCreationMsg = {0}; |
| 429 | ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); |
| 430 | buffer.writeBytes(initiateCreationMsg); |
| 431 | |
| 432 | PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); |
| 433 | PcepMessage message = null; |
| 434 | try { |
| 435 | message = reader.readFrom(buffer); |
| 436 | } catch (PcepParseException e) { |
| 437 | e.printStackTrace(); |
| 438 | } |
| 439 | |
| 440 | if (message instanceof PcepInitiateMsg) { |
| 441 | ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); |
| 442 | message.writeTo(buf); |
| 443 | testInitiateCreationMsg = buf.array(); |
| 444 | |
| 445 | int iReadLen = buf.writerIndex() - 0; |
| 446 | testInitiateCreationMsg = new byte[iReadLen]; |
| 447 | buf.readBytes(testInitiateCreationMsg, 0, iReadLen); |
| 448 | |
| 449 | if (Arrays.equals(initiateCreationMsg, testInitiateCreationMsg)) { |
| 450 | Assert.assertArrayEquals(initiateCreationMsg, testInitiateCreationMsg); |
| 451 | log.debug("PCInitiate Msg are equal :" + initiateCreationMsg); |
| 452 | } else { |
| 453 | Assert.fail("test case failed"); |
| 454 | log.debug("not equal"); |
| 455 | } |
| 456 | } else { |
| 457 | Assert.fail("test case failed"); |
| 458 | log.debug("not equal"); |
| 459 | } |
| 460 | } |
| 461 | |
| 462 | @Test |
| 463 | public void initiateMessageTest9() throws PcepParseException { |
| 464 | |
| 465 | /* SRP, LSP (StatefulIPv4LspIdentidiersTlv), |
| 466 | * END-POINT, ERO. |
| 467 | */ |
| 468 | byte[] initiateCreationMsg = new byte[] {0x20, 0x0C, 0x00, (byte) 0x3c, |
| 469 | 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object |
| 470 | 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object |
| 471 | 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv |
| 472 | (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, |
| 473 | (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, |
| 474 | 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object |
| 475 | 0x07, 0x10, 0x00, 0x04}; |
| 476 | |
| 477 | byte[] testInitiateCreationMsg = {0}; |
| 478 | ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); |
| 479 | buffer.writeBytes(initiateCreationMsg); |
| 480 | |
| 481 | PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); |
| 482 | PcepMessage message = null; |
| 483 | try { |
| 484 | message = reader.readFrom(buffer); |
| 485 | } catch (PcepParseException e) { |
| 486 | e.printStackTrace(); |
| 487 | } |
| 488 | |
| 489 | if (message instanceof PcepInitiateMsg) { |
| 490 | ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); |
| 491 | message.writeTo(buf); |
| 492 | testInitiateCreationMsg = buf.array(); |
| 493 | |
| 494 | int iReadLen = buf.writerIndex() - 0; |
| 495 | testInitiateCreationMsg = new byte[iReadLen]; |
| 496 | buf.readBytes(testInitiateCreationMsg, 0, iReadLen); |
| 497 | |
| 498 | if (Arrays.equals(initiateCreationMsg, testInitiateCreationMsg)) { |
| 499 | Assert.assertArrayEquals(initiateCreationMsg, testInitiateCreationMsg); |
| 500 | log.debug("PCInitiate Msg are equal :" + initiateCreationMsg); |
| 501 | } else { |
| 502 | Assert.fail("test case failed"); |
| 503 | log.debug("not equal"); |
| 504 | } |
| 505 | } else { |
| 506 | Assert.fail("test case failed"); |
| 507 | log.debug("not equal"); |
| 508 | } |
| 509 | } |
| 510 | |
| 511 | @Test |
| 512 | public void initiateMessageTest10() throws PcepParseException { |
| 513 | |
| 514 | /* SRP, LSP (StatefulIPv4LspIdentidiersTlv, StatefulRsvpErrorSpecTlv). |
| 515 | */ |
| 516 | byte[] initiateDeletionMsg = new byte[] {0x20, 0x0C, 0x00, 0x44, |
| 517 | 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, //SRP object |
| 518 | 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathTlv |
| 519 | 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object |
| 520 | 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv |
| 521 | (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, (byte) 0xb6, 0x02, 0x4e, 0x1f, |
| 522 | (byte) 0xb6, 0x02, 0x4e, 0x20, 0x00, 0x11, 0x00, 0x04, 0x54, 0x31, 0x32, 0x33, //SymbolicPathNameTlv |
| 523 | 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08 //StatefulLspErrorCodeTlv |
| 524 | }; |
| 525 | |
| 526 | byte[] testInitiateDeletionMsg = {0}; |
| 527 | ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); |
| 528 | buffer.writeBytes(initiateDeletionMsg); |
| 529 | |
| 530 | PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); |
| 531 | PcepMessage message = null; |
| 532 | try { |
| 533 | message = reader.readFrom(buffer); |
| 534 | } catch (PcepParseException e) { |
| 535 | e.printStackTrace(); |
| 536 | } |
| 537 | |
| 538 | if (message instanceof PcepInitiateMsg) { |
| 539 | ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); |
| 540 | message.writeTo(buf); |
| 541 | testInitiateDeletionMsg = buf.array(); |
| 542 | |
| 543 | int iReadLen = buf.writerIndex() - 0; |
| 544 | testInitiateDeletionMsg = new byte[iReadLen]; |
| 545 | buf.readBytes(testInitiateDeletionMsg, 0, iReadLen); |
| 546 | |
| 547 | if (Arrays.equals(initiateDeletionMsg, testInitiateDeletionMsg)) { |
| 548 | Assert.assertArrayEquals(initiateDeletionMsg, testInitiateDeletionMsg); |
| 549 | log.debug("PCInitiate Msg are equal :" + initiateDeletionMsg); |
| 550 | } else { |
| 551 | Assert.fail("test case failed"); |
| 552 | log.debug("not equal"); |
| 553 | } |
| 554 | } else { |
| 555 | Assert.fail("test case failed"); |
| 556 | log.debug("not equal"); |
| 557 | } |
| 558 | } |
| 559 | |
| 560 | @Test |
| 561 | public void initiateMessageTest11() throws PcepParseException { |
| 562 | |
| 563 | /* SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv, |
| 564 | StatefulLspErrorCodeTlv).*/ |
| 565 | byte[] initiateDeletionMsg = new byte[] {0x20, 0x0C, 0x00, 0x44, |
| 566 | 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, //SRP object |
| 567 | 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathTlv |
| 568 | 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object |
| 569 | 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv |
| 570 | (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, |
| 571 | (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, |
| 572 | 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathTlv |
| 573 | 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08}; //StatefulLspErrorCodeTlv |
| 574 | |
| 575 | byte[] testInitiateDeletionMsg = {0}; |
| 576 | ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); |
| 577 | buffer.writeBytes(initiateDeletionMsg); |
| 578 | |
| 579 | PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); |
| 580 | PcepMessage message = null; |
| 581 | try { |
| 582 | message = reader.readFrom(buffer); |
| 583 | } catch (PcepParseException e) { |
| 584 | e.printStackTrace(); |
| 585 | } |
| 586 | |
| 587 | if (message instanceof PcepInitiateMsg) { |
| 588 | ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); |
| 589 | message.writeTo(buf); |
| 590 | testInitiateDeletionMsg = buf.array(); |
| 591 | |
| 592 | int iReadLen = buf.writerIndex() - 0; |
| 593 | testInitiateDeletionMsg = new byte[iReadLen]; |
| 594 | buf.readBytes(testInitiateDeletionMsg, 0, iReadLen); |
| 595 | |
| 596 | if (Arrays.equals(initiateDeletionMsg, testInitiateDeletionMsg)) { |
| 597 | Assert.assertArrayEquals(initiateDeletionMsg, testInitiateDeletionMsg); |
| 598 | log.debug("PCInitiate Msg are equal :" + initiateDeletionMsg); |
| 599 | } else { |
| 600 | Assert.fail("test case failed"); |
| 601 | log.debug("not equal"); |
| 602 | } |
| 603 | } else { |
| 604 | Assert.fail("test case failed"); |
| 605 | log.debug("not equal"); |
| 606 | } |
| 607 | } |
| 608 | |
| 609 | @Test |
| 610 | public void initiateMessageTest12() throws PcepParseException { |
| 611 | |
| 612 | /* SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv). |
| 613 | */ |
| 614 | byte[] initiateDeletionMsg = new byte[] {0x20, 0x0C, 0x00, 0x3c, |
| 615 | 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, //SRP object |
| 616 | 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathTlv |
| 617 | 0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x10, 0x03, 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv |
| 618 | (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, |
| 619 | (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, |
| 620 | 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00 //SymbolicPathNameTlv |
| 621 | }; |
| 622 | |
| 623 | byte[] testInitiateDeletionMsg = {0}; |
| 624 | ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); |
| 625 | buffer.writeBytes(initiateDeletionMsg); |
| 626 | |
| 627 | PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); |
| 628 | PcepMessage message = null; |
| 629 | try { |
| 630 | message = reader.readFrom(buffer); |
| 631 | } catch (PcepParseException e) { |
| 632 | e.printStackTrace(); |
| 633 | } |
| 634 | |
| 635 | if (message instanceof PcepInitiateMsg) { |
| 636 | ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); |
| 637 | message.writeTo(buf); |
| 638 | testInitiateDeletionMsg = buf.array(); |
| 639 | |
| 640 | int iReadLen = buf.writerIndex() - 0; |
| 641 | testInitiateDeletionMsg = new byte[iReadLen]; |
| 642 | buf.readBytes(testInitiateDeletionMsg, 0, iReadLen); |
| 643 | |
| 644 | if (Arrays.equals(initiateDeletionMsg, testInitiateDeletionMsg)) { |
| 645 | Assert.assertArrayEquals(initiateDeletionMsg, testInitiateDeletionMsg); |
| 646 | log.debug("PCInitiate Msg are equal :" + initiateDeletionMsg); |
| 647 | } else { |
| 648 | Assert.fail("test case failed"); |
| 649 | log.debug("not equal"); |
| 650 | } |
| 651 | } else { |
| 652 | Assert.fail("test case failed"); |
| 653 | log.debug("not equal"); |
| 654 | } |
| 655 | } |
| 656 | |
| 657 | @Test |
| 658 | public void initiateMessageTest13() throws PcepParseException { |
| 659 | |
| 660 | /* SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv). |
| 661 | */ |
| 662 | byte[] initiateDeletionMsg = new byte[] {0x20, 0x0C, 0x00, 0x3c, |
| 663 | 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, //SRP object |
| 664 | 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathTlv |
| 665 | 0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x10, 0x03, 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv |
| 666 | (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, |
| 667 | (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, |
| 668 | 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00 }; //SymbolicPathNameTlv |
| 669 | |
| 670 | byte[] testInitiateDeletionMsg = {0}; |
| 671 | ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); |
| 672 | buffer.writeBytes(initiateDeletionMsg); |
| 673 | |
| 674 | PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); |
| 675 | PcepMessage message = null; |
| 676 | try { |
| 677 | message = reader.readFrom(buffer); |
| 678 | } catch (PcepParseException e) { |
| 679 | e.printStackTrace(); |
| 680 | } |
| 681 | |
| 682 | if (message instanceof PcepInitiateMsg) { |
| 683 | ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); |
| 684 | message.writeTo(buf); |
| 685 | testInitiateDeletionMsg = buf.array(); |
| 686 | |
| 687 | int iReadLen = buf.writerIndex() - 0; |
| 688 | testInitiateDeletionMsg = new byte[iReadLen]; |
| 689 | buf.readBytes(testInitiateDeletionMsg, 0, iReadLen); |
| 690 | |
| 691 | if (Arrays.equals(initiateDeletionMsg, testInitiateDeletionMsg)) { |
| 692 | Assert.assertArrayEquals(initiateDeletionMsg, testInitiateDeletionMsg); |
| 693 | log.debug("PCInitiate Msg are equal :" + initiateDeletionMsg); |
| 694 | } else { |
| 695 | Assert.fail("test case failed"); |
| 696 | log.debug("not equal"); |
| 697 | } |
| 698 | } else { |
| 699 | Assert.fail("test case failed"); |
| 700 | log.debug("not equal"); |
| 701 | } |
| 702 | } |
| 703 | |
| 704 | @Test |
| 705 | public void initiateMessageTest14() throws PcepParseException { |
| 706 | |
| 707 | /* SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv). |
| 708 | */ |
| 709 | byte[] initiateDeletionMsg = new byte[] {0x20, 0x0C, 0x00, 0x34, |
| 710 | 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, //SRP object |
| 711 | 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathTlv |
| 712 | 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object |
| 713 | 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv |
| 714 | (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, |
| 715 | (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20 }; |
| 716 | |
| 717 | byte[] testInitiateDeletionMsg = {0}; |
| 718 | ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); |
| 719 | buffer.writeBytes(initiateDeletionMsg); |
| 720 | |
| 721 | PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); |
| 722 | PcepMessage message = null; |
| 723 | try { |
| 724 | message = reader.readFrom(buffer); |
| 725 | } catch (PcepParseException e) { |
| 726 | e.printStackTrace(); |
| 727 | } |
| 728 | |
| 729 | if (message instanceof PcepInitiateMsg) { |
| 730 | ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); |
| 731 | message.writeTo(buf); |
| 732 | testInitiateDeletionMsg = buf.array(); |
| 733 | |
| 734 | int iReadLen = buf.writerIndex() - 0; |
| 735 | testInitiateDeletionMsg = new byte[iReadLen]; |
| 736 | buf.readBytes(testInitiateDeletionMsg, 0, iReadLen); |
| 737 | |
| 738 | if (Arrays.equals(initiateDeletionMsg, testInitiateDeletionMsg)) { |
| 739 | Assert.assertArrayEquals(initiateDeletionMsg, testInitiateDeletionMsg); |
| 740 | log.debug("PCInitiate Msg are equal :" + initiateDeletionMsg); |
| 741 | } else { |
| 742 | Assert.fail("test case failed"); |
| 743 | log.debug("not equal"); |
| 744 | } |
| 745 | } else { |
| 746 | Assert.fail("test case failed"); |
| 747 | log.debug("not equal"); |
| 748 | } |
| 749 | } |
| 750 | |
| 751 | @Test |
| 752 | public void initiateMessageTest15() throws PcepParseException { |
| 753 | |
| 754 | /* SRP, LSP (StatefulIPv4LspIdentidiersTlv). |
| 755 | */ |
| 756 | byte[] initiateDeletionMsg = new byte[] {0x20, 0x0C, 0x00, 0x2c, |
| 757 | 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, //SRP object |
| 758 | 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object |
| 759 | 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv |
| 760 | (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, |
| 761 | (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20}; |
| 762 | |
| 763 | byte[] testInitiateDeletionMsg = {0}; |
| 764 | ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); |
| 765 | buffer.writeBytes(initiateDeletionMsg); |
| 766 | |
| 767 | PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); |
| 768 | PcepMessage message = null; |
| 769 | try { |
| 770 | message = reader.readFrom(buffer); |
| 771 | } catch (PcepParseException e) { |
| 772 | e.printStackTrace(); |
| 773 | } |
| 774 | |
| 775 | if (message instanceof PcepInitiateMsg) { |
| 776 | ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); |
| 777 | message.writeTo(buf); |
| 778 | testInitiateDeletionMsg = buf.array(); |
| 779 | |
| 780 | int iReadLen = buf.writerIndex() - 0; |
| 781 | testInitiateDeletionMsg = new byte[iReadLen]; |
| 782 | buf.readBytes(testInitiateDeletionMsg, 0, iReadLen); |
| 783 | |
| 784 | if (Arrays.equals(initiateDeletionMsg, testInitiateDeletionMsg)) { |
| 785 | Assert.assertArrayEquals(initiateDeletionMsg, testInitiateDeletionMsg); |
| 786 | log.debug("PCInitiate Msg are equal :" + initiateDeletionMsg); |
| 787 | } else { |
| 788 | Assert.fail("test case failed"); |
| 789 | log.debug("not equal"); |
| 790 | } |
| 791 | } else { |
| 792 | Assert.fail("test case failed"); |
| 793 | log.debug("not equal"); |
| 794 | } |
| 795 | } |
| 796 | |
| 797 | @Test |
| 798 | public void initiateMessageTest16() throws PcepParseException { |
| 799 | |
| 800 | //srp,lsp (StatefulIPv4LspIdentidiersTlv),end-point,ero,lspa |
| 801 | byte[] initiateCreationMsg = new byte[] {0x20, 0x0C, 0x00, (byte) 0x50, |
| 802 | 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object |
| 803 | 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object |
| 804 | 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv |
| 805 | (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, |
| 806 | (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, |
| 807 | 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object |
| 808 | 0x07, 0x10, 0x00, 0x04, //ERO object |
| 809 | 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object |
| 810 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; |
| 811 | |
| 812 | byte[] testInitiateCreationMsg = {0}; |
| 813 | ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); |
| 814 | buffer.writeBytes(initiateCreationMsg); |
| 815 | |
| 816 | PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); |
| 817 | PcepMessage message = null; |
| 818 | try { |
| 819 | message = reader.readFrom(buffer); |
| 820 | } catch (PcepParseException e) { |
| 821 | e.printStackTrace(); |
| 822 | } |
| 823 | |
| 824 | if (message instanceof PcepInitiateMsg) { |
| 825 | ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); |
| 826 | message.writeTo(buf); |
| 827 | testInitiateCreationMsg = buf.array(); |
| 828 | |
| 829 | int iReadLen = buf.writerIndex() - 0; |
| 830 | testInitiateCreationMsg = new byte[iReadLen]; |
| 831 | buf.readBytes(testInitiateCreationMsg, 0, iReadLen); |
| 832 | |
| 833 | if (Arrays.equals(initiateCreationMsg, testInitiateCreationMsg)) { |
| 834 | Assert.assertArrayEquals(initiateCreationMsg, testInitiateCreationMsg); |
| 835 | log.debug("PCInitiate Msg are equal :" + initiateCreationMsg); |
| 836 | } else { |
| 837 | Assert.fail("test case failed"); |
| 838 | log.debug("not equal"); |
| 839 | } |
| 840 | } else { |
| 841 | Assert.fail("test case failed"); |
| 842 | log.debug("not equal"); |
| 843 | } |
| 844 | } |
| 845 | |
| 846 | @Test |
| 847 | public void initiateMessageTest17() throws PcepParseException { |
| 848 | |
| 849 | //srp,lsp (StatefulIPv4LspIdentidiersTlv),end-point,ero,lspa,bandwidth |
| 850 | byte[] initiateCreationMsg = new byte[] {0x20, 0x0C, 0x00, (byte) 0x58, |
| 851 | 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object |
| 852 | 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object |
| 853 | 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv |
| 854 | (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, |
| 855 | (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, |
| 856 | 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object |
| 857 | 0x07, 0x10, 0x00, 0x04, //ERO object |
| 858 | 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object |
| 859 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 860 | 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00}; //Bandwidth object |
| 861 | |
| 862 | byte[] testInitiateCreationMsg = {0}; |
| 863 | ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); |
| 864 | buffer.writeBytes(initiateCreationMsg); |
| 865 | |
| 866 | PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); |
| 867 | PcepMessage message = null; |
| 868 | try { |
| 869 | message = reader.readFrom(buffer); |
| 870 | } catch (PcepParseException e) { |
| 871 | e.printStackTrace(); |
| 872 | } |
| 873 | |
| 874 | if (message instanceof PcepInitiateMsg) { |
| 875 | ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); |
| 876 | message.writeTo(buf); |
| 877 | testInitiateCreationMsg = buf.array(); |
| 878 | |
| 879 | int iReadLen = buf.writerIndex() - 0; |
| 880 | testInitiateCreationMsg = new byte[iReadLen]; |
| 881 | buf.readBytes(testInitiateCreationMsg, 0, iReadLen); |
| 882 | |
| 883 | if (Arrays.equals(initiateCreationMsg, testInitiateCreationMsg)) { |
| 884 | Assert.assertArrayEquals(initiateCreationMsg, testInitiateCreationMsg); |
| 885 | log.debug("PCInitiate Msg are equal :" + initiateCreationMsg); |
| 886 | } else { |
| 887 | Assert.fail("test case failed"); |
| 888 | log.debug("not equal"); |
| 889 | } |
| 890 | } else { |
| 891 | Assert.fail("test case failed"); |
| 892 | log.debug("not equal"); |
| 893 | } |
| 894 | } |
| 895 | |
| 896 | @Test |
| 897 | public void initiateMessageTest18() throws PcepParseException { |
| 898 | //srp,lsp (StatefulIPv4LspIdentidiersTlv),end-point,ero,lspa,bandwidth,metric-list |
| 899 | byte[] initiateCreationMsg = new byte[] {0x20, 0x0C, 0x00, (byte) 0x64, |
| 900 | 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object |
| 901 | 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object |
| 902 | 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv |
| 903 | (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, |
| 904 | (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, |
| 905 | 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object |
| 906 | 0x07, 0x10, 0x00, 0x04, //ERO object |
| 907 | 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object |
| 908 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 909 | 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object |
| 910 | 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20}; //Metric object |
| 911 | |
| 912 | byte[] testInitiateCreationMsg = {0}; |
| 913 | ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); |
| 914 | buffer.writeBytes(initiateCreationMsg); |
| 915 | |
| 916 | PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); |
| 917 | PcepMessage message = null; |
| 918 | try { |
| 919 | message = reader.readFrom(buffer); |
| 920 | } catch (PcepParseException e) { |
| 921 | e.printStackTrace(); |
| 922 | } |
| 923 | |
| 924 | if (message instanceof PcepInitiateMsg) { |
| 925 | ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); |
| 926 | message.writeTo(buf); |
| 927 | testInitiateCreationMsg = buf.array(); |
| 928 | |
| 929 | int iReadLen = buf.writerIndex() - 0; |
| 930 | testInitiateCreationMsg = new byte[iReadLen]; |
| 931 | buf.readBytes(testInitiateCreationMsg, 0, iReadLen); |
| 932 | |
| 933 | if (Arrays.equals(initiateCreationMsg, testInitiateCreationMsg)) { |
| 934 | Assert.assertArrayEquals(initiateCreationMsg, testInitiateCreationMsg); |
| 935 | log.debug("PCInitiate Msg are equal :" + initiateCreationMsg); |
| 936 | } else { |
| 937 | Assert.fail("test case failed"); |
| 938 | log.debug("not equal"); |
| 939 | } |
| 940 | } else { |
| 941 | Assert.fail("test case failed"); |
| 942 | log.debug("not equal"); |
| 943 | } |
| 944 | } |
| 945 | |
| 946 | @Test |
| 947 | public void initiateMessageTest19() throws PcepParseException { |
| 948 | //srp,lsp(all tlvs),end-point,ero,lspa,bandwidth,metric-list |
| 949 | byte[] initiateCreationMsg = new byte[] {0x20, 0x0C, 0x00, (byte) 0x74, |
| 950 | 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object |
| 951 | 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object |
| 952 | 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv |
| 953 | (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, |
| 954 | (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, |
| 955 | 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathTlv |
| 956 | 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, |
| 957 | 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object |
| 958 | 0x07, 0x10, 0x00, 0x04, //ERO object |
| 959 | 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object |
| 960 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 961 | 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object |
| 962 | 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20}; //Metric object |
| 963 | |
| 964 | byte[] testInitiateCreationMsg = {0}; |
| 965 | ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); |
| 966 | buffer.writeBytes(initiateCreationMsg); |
| 967 | |
| 968 | PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); |
| 969 | PcepMessage message = null; |
| 970 | try { |
| 971 | message = reader.readFrom(buffer); |
| 972 | } catch (PcepParseException e) { |
| 973 | e.printStackTrace(); |
| 974 | } |
| 975 | |
| 976 | if (message instanceof PcepInitiateMsg) { |
| 977 | ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); |
| 978 | message.writeTo(buf); |
| 979 | testInitiateCreationMsg = buf.array(); |
| 980 | |
| 981 | int iReadLen = buf.writerIndex() - 0; |
| 982 | testInitiateCreationMsg = new byte[iReadLen]; |
| 983 | buf.readBytes(testInitiateCreationMsg, 0, iReadLen); |
| 984 | |
| 985 | if (Arrays.equals(initiateCreationMsg, testInitiateCreationMsg)) { |
| 986 | Assert.assertArrayEquals(initiateCreationMsg, testInitiateCreationMsg); |
| 987 | log.debug("PCInitiate Msg are equal :" + initiateCreationMsg); |
| 988 | } else { |
| 989 | Assert.fail("test case failed"); |
| 990 | log.debug("not equal"); |
| 991 | } |
| 992 | } else { |
| 993 | Assert.fail("test case failed"); |
| 994 | log.debug("not equal"); |
| 995 | } |
| 996 | } |
| 997 | |
| 998 | @Test |
| 999 | public void initiateMessageTest20() throws PcepParseException { |
| 1000 | /* srp,lsp (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, srp, |
| 1001 | * lsp(SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv). |
| 1002 | */ |
| 1003 | byte[] initiateDeletionMsg = new byte[] {0x20, 0x0C, 0x00, 0x64, |
| 1004 | 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, //SRP object |
| 1005 | 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv |
| 1006 | 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object |
| 1007 | 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv |
| 1008 | (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, |
| 1009 | (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, |
| 1010 | 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, //SRP object |
| 1011 | 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv |
| 1012 | 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object |
| 1013 | 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv |
| 1014 | (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, |
| 1015 | (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20}; |
| 1016 | |
| 1017 | byte[] testInitiateDeletionMsg = {0}; |
| 1018 | ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); |
| 1019 | buffer.writeBytes(initiateDeletionMsg); |
| 1020 | |
| 1021 | PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); |
| 1022 | PcepMessage message = null; |
| 1023 | try { |
| 1024 | message = reader.readFrom(buffer); |
| 1025 | } catch (PcepParseException e) { |
| 1026 | e.printStackTrace(); |
| 1027 | } |
| 1028 | |
| 1029 | if (message instanceof PcepInitiateMsg) { |
| 1030 | ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); |
| 1031 | message.writeTo(buf); |
| 1032 | testInitiateDeletionMsg = buf.array(); |
| 1033 | |
| 1034 | int iReadLen = buf.writerIndex() - 0; |
| 1035 | testInitiateDeletionMsg = new byte[iReadLen]; |
| 1036 | buf.readBytes(testInitiateDeletionMsg, 0, iReadLen); |
| 1037 | |
| 1038 | if (Arrays.equals(initiateDeletionMsg, testInitiateDeletionMsg)) { |
| 1039 | Assert.assertArrayEquals(initiateDeletionMsg, testInitiateDeletionMsg); |
| 1040 | log.debug("PCInitiate Msg are equal :" + initiateDeletionMsg); |
| 1041 | } else { |
| 1042 | Assert.fail("test case failed"); |
| 1043 | log.debug("not equal"); |
| 1044 | } |
| 1045 | } else { |
| 1046 | Assert.fail("test case failed"); |
| 1047 | log.debug("not equal"); |
| 1048 | } |
| 1049 | } |
| 1050 | |
| 1051 | @Test |
| 1052 | public void initiateMessageTest21() throws PcepParseException { |
| 1053 | /*srp,lsp(StatefulIPv4LspIdentidiersTlv),end-point,ero, |
| 1054 | * srp,lsp(StatefulIPv4LspIdentidiersTlv),end-point,ero |
| 1055 | */ |
| 1056 | byte[] initiateCreationMsg = new byte[] {0x20, 0x0C, 0x00, (byte) 0x94, |
| 1057 | 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object |
| 1058 | 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object |
| 1059 | 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv |
| 1060 | (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, |
| 1061 | (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, |
| 1062 | 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object |
| 1063 | 0x07, 0x10, 0x00, 0x14, //ERO object |
| 1064 | 0x01, 0x08, 0x0C, 0x01, 0x01, 0x01, 0x00, 0x00, |
| 1065 | 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00, |
| 1066 | 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object |
| 1067 | 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object |
| 1068 | 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv |
| 1069 | (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, |
| 1070 | (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, |
| 1071 | 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object |
| 1072 | 0x07, 0x10, 0x00, 0x14, //ERO object |
| 1073 | 0x01, 0x08, 0x0C, 0x01, 0x01, 0x01, 0x00, 0x00, |
| 1074 | 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00}; |
| 1075 | |
| 1076 | byte[] testInitiateCreationMsg = {0}; |
| 1077 | ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); |
| 1078 | buffer.writeBytes(initiateCreationMsg); |
| 1079 | |
| 1080 | PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); |
| 1081 | PcepMessage message = null; |
| 1082 | try { |
| 1083 | message = reader.readFrom(buffer); |
| 1084 | } catch (PcepParseException e) { |
| 1085 | e.printStackTrace(); |
| 1086 | } |
| 1087 | |
| 1088 | if (message instanceof PcepInitiateMsg) { |
| 1089 | ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); |
| 1090 | message.writeTo(buf); |
| 1091 | testInitiateCreationMsg = buf.array(); |
| 1092 | |
| 1093 | int iReadLen = buf.writerIndex() - 0; |
| 1094 | testInitiateCreationMsg = new byte[iReadLen]; |
| 1095 | buf.readBytes(testInitiateCreationMsg, 0, iReadLen); |
| 1096 | |
| 1097 | if (Arrays.equals(initiateCreationMsg, testInitiateCreationMsg)) { |
| 1098 | Assert.assertArrayEquals(initiateCreationMsg, testInitiateCreationMsg); |
| 1099 | log.debug("PCInitiate Msg are equal :" + initiateCreationMsg); |
| 1100 | } else { |
| 1101 | Assert.fail("test case failed"); |
| 1102 | log.debug("not equal"); |
| 1103 | } |
| 1104 | } else { |
| 1105 | Assert.fail("test case failed"); |
| 1106 | log.debug("not equal"); |
| 1107 | } |
| 1108 | } |
| 1109 | |
| 1110 | @Test |
| 1111 | public void initiateMessageTest22() throws PcepParseException { |
| 1112 | /*srp,lsp(StatefulIPv4LspIdentidiersTlv),end-point,ero, |
| 1113 | * srp,lsp(StatefulIPv4LspIdentidiersTlv),end-point,ero,lspa |
| 1114 | */ |
| 1115 | byte[] initiateCreationMsg = new byte[] {0x20, 0x0C, 0x00, (byte) 0xA8, |
| 1116 | 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object |
| 1117 | 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object |
| 1118 | 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv |
| 1119 | (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, |
| 1120 | (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, |
| 1121 | 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object |
| 1122 | 0x07, 0x10, 0x00, 0x14, //ERO object |
| 1123 | 0x01, 0x08, 0x0C, 0x01, 0x01, 0x01, 0x00, 0x00, |
| 1124 | 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00, |
| 1125 | 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object |
| 1126 | 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object |
| 1127 | 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv |
| 1128 | (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, |
| 1129 | (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, |
| 1130 | 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object |
| 1131 | 0x07, 0x10, 0x00, 0x14, //ERO object |
| 1132 | 0x01, 0x08, 0x0C, 0x01, 0x01, 0x01, 0x00, 0x00, |
| 1133 | 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00, |
| 1134 | 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object |
| 1135 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; |
| 1136 | |
| 1137 | byte[] testInitiateCreationMsg = {0}; |
| 1138 | ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); |
| 1139 | buffer.writeBytes(initiateCreationMsg); |
| 1140 | |
| 1141 | PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); |
| 1142 | PcepMessage message = null; |
| 1143 | try { |
| 1144 | message = reader.readFrom(buffer); |
| 1145 | } catch (PcepParseException e) { |
| 1146 | e.printStackTrace(); |
| 1147 | } |
| 1148 | |
| 1149 | if (message instanceof PcepInitiateMsg) { |
| 1150 | ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); |
| 1151 | message.writeTo(buf); |
| 1152 | testInitiateCreationMsg = buf.array(); |
| 1153 | |
| 1154 | int iReadLen = buf.writerIndex() - 0; |
| 1155 | testInitiateCreationMsg = new byte[iReadLen]; |
| 1156 | buf.readBytes(testInitiateCreationMsg, 0, iReadLen); |
| 1157 | |
| 1158 | if (Arrays.equals(initiateCreationMsg, testInitiateCreationMsg)) { |
| 1159 | Assert.assertArrayEquals(initiateCreationMsg, testInitiateCreationMsg); |
| 1160 | log.debug("PCInitiate Msg are equal :" + initiateCreationMsg); |
| 1161 | } else { |
| 1162 | Assert.fail("test case failed"); |
| 1163 | log.debug("not equal"); |
| 1164 | } |
| 1165 | } else { |
| 1166 | Assert.fail("test case failed"); |
| 1167 | log.debug("not equal"); |
| 1168 | } |
| 1169 | } |
| 1170 | |
| 1171 | @Test |
| 1172 | public void initiateMessageTest23() throws PcepParseException { |
| 1173 | /*srp,lsp(StatefulIPv4LspIdentidiersTlv),end-point,ero, |
| 1174 | * srp,lsp(StatefulIPv4LspIdentidiersTlv),end-point,ero,lspa,bandwidth |
| 1175 | */ |
| 1176 | byte[] initiateCreationMsg = new byte[] {0x20, 0x0C, 0x00, (byte) 0xB0, |
| 1177 | 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object |
| 1178 | 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object |
| 1179 | 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv |
| 1180 | (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, |
| 1181 | (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, |
| 1182 | 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object |
| 1183 | 0x07, 0x10, 0x00, 0x14, //ERO object |
| 1184 | 0x01, 0x08, 0x0C, 0x01, 0x01, 0x01, 0x00, 0x00, |
| 1185 | 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00, |
| 1186 | 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object |
| 1187 | 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object |
| 1188 | 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv |
| 1189 | (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, |
| 1190 | (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, |
| 1191 | 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object |
| 1192 | 0x07, 0x10, 0x00, 0x14, //ERO object |
| 1193 | 0x01, 0x08, 0x0C, 0x01, 0x01, 0x01, 0x00, 0x00, |
| 1194 | 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00, |
| 1195 | 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object |
| 1196 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 1197 | 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00}; //Bandwidth object |
| 1198 | |
| 1199 | byte[] testInitiateCreationMsg = {0}; |
| 1200 | ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); |
| 1201 | buffer.writeBytes(initiateCreationMsg); |
| 1202 | |
| 1203 | PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); |
| 1204 | PcepMessage message = null; |
| 1205 | try { |
| 1206 | message = reader.readFrom(buffer); |
| 1207 | } catch (PcepParseException e) { |
| 1208 | e.printStackTrace(); |
| 1209 | } |
| 1210 | |
| 1211 | if (message instanceof PcepInitiateMsg) { |
| 1212 | ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); |
| 1213 | message.writeTo(buf); |
| 1214 | testInitiateCreationMsg = buf.array(); |
| 1215 | |
| 1216 | int iReadLen = buf.writerIndex() - 0; |
| 1217 | testInitiateCreationMsg = new byte[iReadLen]; |
| 1218 | buf.readBytes(testInitiateCreationMsg, 0, iReadLen); |
| 1219 | |
| 1220 | if (Arrays.equals(initiateCreationMsg, testInitiateCreationMsg)) { |
| 1221 | Assert.assertArrayEquals(initiateCreationMsg, testInitiateCreationMsg); |
| 1222 | log.debug("PCInitiate Msg are equal :" + initiateCreationMsg); |
| 1223 | } else { |
| 1224 | Assert.fail("test case failed"); |
| 1225 | log.debug("not equal"); |
| 1226 | } |
| 1227 | } else { |
| 1228 | Assert.fail("test case failed"); |
| 1229 | log.debug("not equal"); |
| 1230 | } |
| 1231 | } |
| 1232 | |
| 1233 | @Test |
| 1234 | public void initiateMessageTest24() throws PcepParseException { |
| 1235 | /*srp,lsp(StatefulIPv4LspIdentidiersTlv),end-point,ero, |
| 1236 | * srp,lsp(StatefulIPv4LspIdentidiersTlv),end-point,ero,lspa,bandwidth*/ |
| 1237 | byte[] initiateCreationMsg = new byte[] {0x20, 0x0C, 0x00, (byte) 0xBC, |
| 1238 | 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object |
| 1239 | 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object |
| 1240 | 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv |
| 1241 | (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, |
| 1242 | (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, |
| 1243 | 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object |
| 1244 | 0x07, 0x10, 0x00, 0x14, //ERO object |
| 1245 | 0x01, 0x08, 0x0C, 0x01, 0x01, 0x01, 0x00, 0x00, |
| 1246 | 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00, |
| 1247 | 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object |
| 1248 | 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object |
| 1249 | 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv |
| 1250 | (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, |
| 1251 | (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, |
| 1252 | 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object |
| 1253 | 0x07, 0x10, 0x00, 0x14, //ERO object |
| 1254 | 0x01, 0x08, 0x0C, 0x01, 0x01, 0x01, 0x00, 0x00, |
| 1255 | 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00, |
| 1256 | 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object |
| 1257 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 1258 | 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object |
| 1259 | 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20}; //Metric object |
| 1260 | |
| 1261 | byte[] testInitiateCreationMsg = {0}; |
| 1262 | ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); |
| 1263 | buffer.writeBytes(initiateCreationMsg); |
| 1264 | |
| 1265 | PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); |
| 1266 | PcepMessage message = null; |
| 1267 | try { |
| 1268 | message = reader.readFrom(buffer); |
| 1269 | } catch (PcepParseException e) { |
| 1270 | e.printStackTrace(); |
| 1271 | } |
| 1272 | |
| 1273 | if (message instanceof PcepInitiateMsg) { |
| 1274 | ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); |
| 1275 | message.writeTo(buf); |
| 1276 | testInitiateCreationMsg = buf.array(); |
| 1277 | |
| 1278 | int iReadLen = buf.writerIndex() - 0; |
| 1279 | testInitiateCreationMsg = new byte[iReadLen]; |
| 1280 | buf.readBytes(testInitiateCreationMsg, 0, iReadLen); |
| 1281 | |
| 1282 | if (Arrays.equals(initiateCreationMsg, testInitiateCreationMsg)) { |
| 1283 | Assert.assertArrayEquals(initiateCreationMsg, testInitiateCreationMsg); |
| 1284 | log.debug("PCInitiate Msg are equal :" + initiateCreationMsg); |
| 1285 | } else { |
| 1286 | Assert.fail("test case failed"); |
| 1287 | log.debug("not equal"); |
| 1288 | } |
| 1289 | } else { |
| 1290 | Assert.fail("test case failed"); |
| 1291 | log.debug("not equal"); |
| 1292 | } |
| 1293 | } |
| 1294 | |
| 1295 | @Test |
| 1296 | public void initiateMessageTest25() throws PcepParseException { |
| 1297 | |
| 1298 | /*srp,lsp(StatefulIPv4LspIdentidiersTlv),end-point,ero,bandwidth, |
| 1299 | * srp,lsp(StatefulIPv4LspIdentidiersTlv), |
| 1300 | * end-point,ero,lspa,bandwidth,metric-list */ |
| 1301 | byte[] initiateCreationMsg = new byte[] {0x20, 0x0C, 0x00, (byte) 0xC4, |
| 1302 | 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object |
| 1303 | 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object |
| 1304 | 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv |
| 1305 | (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, |
| 1306 | (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, |
| 1307 | 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object |
| 1308 | 0x07, 0x10, 0x00, 0x14, //ERO object |
| 1309 | 0x01, 0x08, 0x0C, 0x01, 0x01, 0x01, 0x00, 0x00, |
| 1310 | 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00, |
| 1311 | 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object |
| 1312 | 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object |
| 1313 | 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object |
| 1314 | 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv |
| 1315 | (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, |
| 1316 | (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, |
| 1317 | 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object |
| 1318 | 0x07, 0x10, 0x00, 0x14, //ERO object |
| 1319 | 0x01, 0x08, 0x0C, 0x01, 0x01, 0x01, 0x00, 0x00, |
| 1320 | 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00, |
| 1321 | 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object |
| 1322 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 1323 | 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object |
| 1324 | 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20}; //Metric object |
| 1325 | |
| 1326 | byte[] testInitiateCreationMsg = {0}; |
| 1327 | ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); |
| 1328 | buffer.writeBytes(initiateCreationMsg); |
| 1329 | |
| 1330 | PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); |
| 1331 | PcepMessage message = null; |
| 1332 | try { |
| 1333 | message = reader.readFrom(buffer); |
| 1334 | } catch (PcepParseException e) { |
| 1335 | e.printStackTrace(); |
| 1336 | } |
| 1337 | |
| 1338 | if (message instanceof PcepInitiateMsg) { |
| 1339 | ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); |
| 1340 | message.writeTo(buf); |
| 1341 | testInitiateCreationMsg = buf.array(); |
| 1342 | |
| 1343 | int iReadLen = buf.writerIndex() - 0; |
| 1344 | testInitiateCreationMsg = new byte[iReadLen]; |
| 1345 | buf.readBytes(testInitiateCreationMsg, 0, iReadLen); |
| 1346 | |
| 1347 | if (Arrays.equals(initiateCreationMsg, testInitiateCreationMsg)) { |
| 1348 | Assert.assertArrayEquals(initiateCreationMsg, testInitiateCreationMsg); |
| 1349 | log.debug("PCInitiate Msg are equal :" + initiateCreationMsg); |
| 1350 | } else { |
| 1351 | Assert.fail("test case failed"); |
| 1352 | log.debug("not equal"); |
| 1353 | } |
| 1354 | } else { |
| 1355 | Assert.fail("test case failed"); |
| 1356 | log.debug("not equal"); |
| 1357 | } |
| 1358 | } |
| 1359 | |
| 1360 | @Test |
| 1361 | public void initiateMessageTest26() throws PcepParseException { |
| 1362 | |
| 1363 | /*srp,lsp(StatefulIPv4LspIdentidiersTlv),end-point,ero,bandwidth,metric-list, |
| 1364 | * srp,lsp(StatefulIPv4LspIdentidiersTlv), |
| 1365 | * end-point,ero,lspa,bandwidth,metric-list */ |
| 1366 | byte[] initiateCreationMsg = new byte[] {0x20, 0x0C, 0x00, (byte) 0xD0, |
| 1367 | 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object |
| 1368 | 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object |
| 1369 | 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv |
| 1370 | (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, |
| 1371 | (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, |
| 1372 | 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object |
| 1373 | 0x07, 0x10, 0x00, 0x14, //ERO object |
| 1374 | 0x01, 0x08, 0x0C, 0x01, 0x01, 0x01, 0x00, 0x00, |
| 1375 | 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00, |
| 1376 | 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object |
| 1377 | 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20, //Metric object |
| 1378 | 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object |
| 1379 | 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object |
| 1380 | 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv |
| 1381 | (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, |
| 1382 | (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, |
| 1383 | 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object |
| 1384 | 0x07, 0x10, 0x00, 0x14, //ERO object |
| 1385 | 0x01, 0x08, 0x0C, 0x01, 0x01, 0x01, 0x00, 0x00, |
| 1386 | 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00, |
| 1387 | 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object |
| 1388 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 1389 | 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object |
| 1390 | 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20}; //Metric object |
| 1391 | |
| 1392 | byte[] testInitiateCreationMsg = {0}; |
| 1393 | ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); |
| 1394 | buffer.writeBytes(initiateCreationMsg); |
| 1395 | |
| 1396 | PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); |
| 1397 | PcepMessage message = null; |
| 1398 | try { |
| 1399 | message = reader.readFrom(buffer); |
| 1400 | } catch (PcepParseException e) { |
| 1401 | e.printStackTrace(); |
| 1402 | } |
| 1403 | |
| 1404 | if (message instanceof PcepInitiateMsg) { |
| 1405 | ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); |
| 1406 | message.writeTo(buf); |
| 1407 | testInitiateCreationMsg = buf.array(); |
| 1408 | |
| 1409 | int iReadLen = buf.writerIndex() - 0; |
| 1410 | testInitiateCreationMsg = new byte[iReadLen]; |
| 1411 | buf.readBytes(testInitiateCreationMsg, 0, iReadLen); |
| 1412 | |
| 1413 | if (Arrays.equals(initiateCreationMsg, testInitiateCreationMsg)) { |
| 1414 | Assert.assertArrayEquals(initiateCreationMsg, testInitiateCreationMsg); |
| 1415 | log.debug("PCInitiate Msg are equal :" + initiateCreationMsg); |
| 1416 | } else { |
| 1417 | Assert.fail("test case failed"); |
| 1418 | log.debug("not equal"); |
| 1419 | } |
| 1420 | } else { |
| 1421 | Assert.fail("test case failed"); |
| 1422 | log.debug("not equal"); |
| 1423 | } |
| 1424 | } |
| 1425 | |
| 1426 | @Test |
| 1427 | public void initiateMessageTest27() throws PcepParseException { |
| 1428 | |
| 1429 | /*srp,lsp(StatefulIPv4LspIdentidiersTlv),end-point,ero,lspa,bandwidth,metric-list, |
| 1430 | * srp,lsp(StatefulIPv4LspIdentidiersTlv), |
| 1431 | * end-point,ero,lspa,bandwidth,metric-list */ |
| 1432 | byte[] initiateCreationMsg = new byte[] {0x20, 0x0C, 0x00, (byte) 0xE4, |
| 1433 | 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object |
| 1434 | 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object |
| 1435 | 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv |
| 1436 | (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, |
| 1437 | (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, |
| 1438 | 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object |
| 1439 | 0x07, 0x10, 0x00, 0x14, //ERO object |
| 1440 | 0x01, 0x08, 0x0C, 0x01, 0x01, 0x01, 0x00, 0x00, |
| 1441 | 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00, |
| 1442 | 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object |
| 1443 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 1444 | 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object |
| 1445 | 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20, //Metric object |
| 1446 | 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object |
| 1447 | 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object |
| 1448 | 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv |
| 1449 | (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, |
| 1450 | (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, |
| 1451 | 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object |
| 1452 | 0x07, 0x10, 0x00, 0x14, //ERO object |
| 1453 | 0x01, 0x08, 0x0C, 0x01, 0x01, 0x01, 0x00, 0x00, |
| 1454 | 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00, |
| 1455 | 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object |
| 1456 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 1457 | 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object |
| 1458 | 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20}; //Metric object |
| 1459 | |
| 1460 | byte[] testInitiateCreationMsg = {0}; |
| 1461 | ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); |
| 1462 | buffer.writeBytes(initiateCreationMsg); |
| 1463 | |
| 1464 | PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); |
| 1465 | PcepMessage message = null; |
| 1466 | try { |
| 1467 | message = reader.readFrom(buffer); |
| 1468 | } catch (PcepParseException e) { |
| 1469 | e.printStackTrace(); |
| 1470 | } |
| 1471 | |
| 1472 | if (message instanceof PcepInitiateMsg) { |
| 1473 | ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); |
| 1474 | message.writeTo(buf); |
| 1475 | testInitiateCreationMsg = buf.array(); |
| 1476 | |
| 1477 | int iReadLen = buf.writerIndex() - 0; |
| 1478 | testInitiateCreationMsg = new byte[iReadLen]; |
| 1479 | buf.readBytes(testInitiateCreationMsg, 0, iReadLen); |
| 1480 | |
| 1481 | if (Arrays.equals(initiateCreationMsg, testInitiateCreationMsg)) { |
| 1482 | Assert.assertArrayEquals(initiateCreationMsg, testInitiateCreationMsg); |
| 1483 | log.debug("PCInitiate Msg are equal :" + initiateCreationMsg); |
| 1484 | } else { |
| 1485 | Assert.fail("test case failed"); |
| 1486 | log.debug("not equal"); |
| 1487 | } |
| 1488 | } else { |
| 1489 | Assert.fail("test case failed"); |
| 1490 | log.debug("not equal"); |
| 1491 | } |
| 1492 | } |
| 1493 | } |