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