blob: 52e97b1e679ccca3f702ef92575ae2f4f6e2ef72 [file] [log] [blame]
bharat saraswalf7364db2015-08-11 13:39:31 +05301/*
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 */
16package org.onosproject.pcepio;
17
18import org.jboss.netty.buffer.ChannelBuffer;
19import org.jboss.netty.buffer.ChannelBuffers;
bharat saraswalf7364db2015-08-11 13:39:31 +053020import org.junit.Assert;
bharat saraswalf7364db2015-08-11 13:39:31 +053021import org.junit.Test;
22import org.onosproject.pcepio.exceptions.PcepParseException;
23import org.onosproject.pcepio.protocol.PcepFactories;
24import org.onosproject.pcepio.protocol.PcepMessage;
25import org.onosproject.pcepio.protocol.PcepMessageReader;
26import org.onosproject.pcepio.protocol.PcepUpdateMsg;
27
bharat saraswalf7364db2015-08-11 13:39:31 +053028public class PcepUpdateMsgTest {
Bharat saraswal7092b0e2015-08-24 19:40:59 +053029 /**
30 * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv), ERO in PcUpd message.
31 *
32 * @throws PcepParseException when message paring fails
33 */
bharat saraswalf7364db2015-08-11 13:39:31 +053034 @Test
35 public void pcepUpdateMsgTest1() throws PcepParseException {
Bharat saraswal7092b0e2015-08-24 19:40:59 +053036
bharat saraswalf7364db2015-08-11 13:39:31 +053037 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x30,
38 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
39 0x20, 0x10, 0x00, 0x1C, 0x00, 0x00, 0x10, 0x03, //LSP object
40 0x00, 0x12, 0x00, 0x10, (byte) 0xb6, 0x02, 0x4e, 0x1f, //StatefulIPv4LspIdentidiersTlv
41 0x00, 0x01, (byte) 0x80, 0x01, (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
42 0x07, 0x10, 0x00, 0x04 }; //ERO object
43
44 byte[] testupdateMsg = {0};
45 ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
46 buffer.writeBytes(updateMsg);
47
48 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
49 PcepMessage message = null;
bharat saraswalf7364db2015-08-11 13:39:31 +053050
Bharat saraswal7092b0e2015-08-24 19:40:59 +053051 message = reader.readFrom(buffer);
bharat saraswalf7364db2015-08-11 13:39:31 +053052
Bharat saraswal7092b0e2015-08-24 19:40:59 +053053 Assert.assertTrue("PcepMessage is not instance of PcUpd", (message instanceof PcepUpdateMsg));
54 ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
55 message.writeTo(buf);
56 testupdateMsg = buf.array();
bharat saraswalf7364db2015-08-11 13:39:31 +053057
Bharat saraswal7092b0e2015-08-24 19:40:59 +053058 int readLen = buf.writerIndex() - 0;
59 testupdateMsg = new byte[readLen];
60 buf.readBytes(testupdateMsg, 0, readLen);
bharat saraswalf7364db2015-08-11 13:39:31 +053061
Bharat saraswal7092b0e2015-08-24 19:40:59 +053062 Assert.assertArrayEquals("PcUpd messages are not equal", updateMsg, testupdateMsg);
bharat saraswalf7364db2015-08-11 13:39:31 +053063 }
64
Bharat saraswal7092b0e2015-08-24 19:40:59 +053065 /**
66 * This test case checks for SRP(SymbolicPathNameTlv), LSP (StatefulIPv4LspIdentidiersTlv,
67 * SymbolicPathNameTlv, StatefulLspErrorCodeTlv), ERO, LSPA, Metric-list in PcUpd message.
68 *
69 * @throws PcepParseException when message paring fails
70 */
bharat saraswalf7364db2015-08-11 13:39:31 +053071 @Test
72 public void pcepUpdateMsgTest2() throws PcepParseException {
73
bharat saraswalf7364db2015-08-11 13:39:31 +053074 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x94,
75 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
76 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
77 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object // lsp object
78 0x00, 0x12, 0x00, 0x10, (byte) 0xb6, 0x02, 0x4e, 0x1f, //StatefulIPv4LspIdentidiersTlv
79 0x00, 0x01, (byte) 0x80, 0x01, (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
80 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
81 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
82 0x07, 0x10, 0x00, 0x24, 0x01, 0x08, 0x11, 0x01, //ERO object
83 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
84 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01,
85 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01, 0x01, 0x01, 0x04, 0x00,
86 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
87 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
88 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01,
89 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
90
91 byte[] testupdateMsg = {0};
92 ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
93 buffer.writeBytes(updateMsg);
94
95 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
96 PcepMessage message = null;
bharat saraswalf7364db2015-08-11 13:39:31 +053097
Bharat saraswal7092b0e2015-08-24 19:40:59 +053098 message = reader.readFrom(buffer);
99 Assert.assertTrue("PcepMessage is not instance of PcUpd", (message instanceof PcepUpdateMsg));
100 ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
101 message.writeTo(buf);
102 testupdateMsg = buf.array();
bharat saraswalf7364db2015-08-11 13:39:31 +0530103
Bharat saraswal7092b0e2015-08-24 19:40:59 +0530104 int readLen = buf.writerIndex() - 0;
105 testupdateMsg = new byte[readLen];
106 buf.readBytes(testupdateMsg, 0, readLen);
bharat saraswalf7364db2015-08-11 13:39:31 +0530107
Bharat saraswal7092b0e2015-08-24 19:40:59 +0530108 Assert.assertArrayEquals("PcUpd messages are not equal", updateMsg, testupdateMsg);
bharat saraswalf7364db2015-08-11 13:39:31 +0530109 }
110
Bharat saraswal7092b0e2015-08-24 19:40:59 +0530111 /**
112 * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv),
113 * ERO objects in PcUpd message.
114 *
115 * @throws PcepParseException when message paring fails
116 */
bharat saraswalf7364db2015-08-11 13:39:31 +0530117 @Test
118 public void pcepUpdateMsgTest3() throws PcepParseException {
119
bharat saraswalf7364db2015-08-11 13:39:31 +0530120 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x38,
121 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
122 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
123 0x20, 0x10, 0x00, 0x1C, 0x00, 0x00, 0x10, 0x03, //LSP object
124 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
125 (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
126 (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
127 0x07, 0x10, 0x00, 0x04 }; //ERO object
128
129 byte[] testupdateMsg = {0};
130 ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
131 buffer.writeBytes(updateMsg);
132
133 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
134 PcepMessage message = null;
bharat saraswalf7364db2015-08-11 13:39:31 +0530135
Bharat saraswal7092b0e2015-08-24 19:40:59 +0530136 message = reader.readFrom(buffer);
bharat saraswalf7364db2015-08-11 13:39:31 +0530137
Bharat saraswal7092b0e2015-08-24 19:40:59 +0530138 Assert.assertTrue("PcepMessage is not instance of PcUpd", (message instanceof PcepUpdateMsg));
139 ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
140 message.writeTo(buf);
141 testupdateMsg = buf.array();
bharat saraswalf7364db2015-08-11 13:39:31 +0530142
Bharat saraswal7092b0e2015-08-24 19:40:59 +0530143 int readLen = buf.writerIndex() - 0;
144 testupdateMsg = new byte[readLen];
145 buf.readBytes(testupdateMsg, 0, readLen);
bharat saraswalf7364db2015-08-11 13:39:31 +0530146
Bharat saraswal7092b0e2015-08-24 19:40:59 +0530147 Assert.assertArrayEquals("PcUpd messages are not equal", updateMsg, testupdateMsg);
bharat saraswalf7364db2015-08-11 13:39:31 +0530148 }
149
Bharat saraswal7092b0e2015-08-24 19:40:59 +0530150 /**
151 * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv,
152 * SymbolicPathNameTlv), ERO objects in PcUpd message.
153 *
154 * @throws PcepParseException when message paring fails
155 */
bharat saraswalf7364db2015-08-11 13:39:31 +0530156 @Test
157 public void pcepUpdateMsgTest4() throws PcepParseException {
158
bharat saraswalf7364db2015-08-11 13:39:31 +0530159 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x40,
160 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
161 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
162 0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x10, 0x03, //LSP object
163 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
164 (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
165 (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
166 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
167 0x07, 0x10, 0x00, 0x04 }; //ERO object
168
169 byte[] testupdateMsg = {0};
170 ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
171 buffer.writeBytes(updateMsg);
172
173 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
174 PcepMessage message = null;
bharat saraswalf7364db2015-08-11 13:39:31 +0530175
Bharat saraswal7092b0e2015-08-24 19:40:59 +0530176 message = reader.readFrom(buffer);
bharat saraswalf7364db2015-08-11 13:39:31 +0530177
Bharat saraswal7092b0e2015-08-24 19:40:59 +0530178 Assert.assertTrue("PcepMessage is not instance of PcUpd", (message instanceof PcepUpdateMsg));
179 ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
180 message.writeTo(buf);
181 testupdateMsg = buf.array();
bharat saraswalf7364db2015-08-11 13:39:31 +0530182
Bharat saraswal7092b0e2015-08-24 19:40:59 +0530183 int readLen = buf.writerIndex() - 0;
184 testupdateMsg = new byte[readLen];
185 buf.readBytes(testupdateMsg, 0, readLen);
bharat saraswalf7364db2015-08-11 13:39:31 +0530186
Bharat saraswal7092b0e2015-08-24 19:40:59 +0530187 Assert.assertArrayEquals("PcUpd messages are not equal", updateMsg, testupdateMsg);
bharat saraswalf7364db2015-08-11 13:39:31 +0530188 }
189
Bharat saraswal7092b0e2015-08-24 19:40:59 +0530190 /**
191 * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv,
192 * SymbolicPathNameTlv), ERO objects in PcUpd message.
193 *
194 * @throws PcepParseException when message parsing fails
195 */
bharat saraswalf7364db2015-08-11 13:39:31 +0530196 @Test
197 public void pcepUpdateMsgTest5() throws PcepParseException {
198
bharat saraswalf7364db2015-08-11 13:39:31 +0530199 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x40,
200 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
201 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
202 0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x10, 0x03, //LSP object
203 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
204 (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
205 (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
206 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
207 0x07, 0x10, 0x00, 0x04 }; //ERO object
208
209 byte[] testupdateMsg = {0};
210 ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
211 buffer.writeBytes(updateMsg);
212
213 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
214 PcepMessage message = null;
bharat saraswalf7364db2015-08-11 13:39:31 +0530215
Bharat saraswal7092b0e2015-08-24 19:40:59 +0530216 message = reader.readFrom(buffer);
bharat saraswalf7364db2015-08-11 13:39:31 +0530217
Bharat saraswal7092b0e2015-08-24 19:40:59 +0530218 Assert.assertTrue("PcepMessage is not instance of PcUpd", (message instanceof PcepUpdateMsg));
219 ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
220 message.writeTo(buf);
221 testupdateMsg = buf.array();
bharat saraswalf7364db2015-08-11 13:39:31 +0530222
Bharat saraswal7092b0e2015-08-24 19:40:59 +0530223 int readLen = buf.writerIndex() - 0;
224 testupdateMsg = new byte[readLen];
225 buf.readBytes(testupdateMsg, 0, readLen);
bharat saraswalf7364db2015-08-11 13:39:31 +0530226
Bharat saraswal7092b0e2015-08-24 19:40:59 +0530227 Assert.assertArrayEquals("PcUpd messages are not equal", updateMsg, testupdateMsg);
bharat saraswalf7364db2015-08-11 13:39:31 +0530228 }
229
Bharat saraswal7092b0e2015-08-24 19:40:59 +0530230 /**
231 * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv,
232 * StatefulLspErrorCodeTlv), ERO objects in PcUpd message.
233 *
234 * @throws PcepParseException when message parsing fails
235 */
bharat saraswalf7364db2015-08-11 13:39:31 +0530236 @Test
237 public void pcepUpdateMsgTest6() throws PcepParseException {
238
bharat saraswalf7364db2015-08-11 13:39:31 +0530239 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x48,
240 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
241 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
242 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object
243 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
244 (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
245 (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
246 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
247 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
248 0x07, 0x10, 0x00, 0x04 };
249
250 byte[] testupdateMsg = {0};
251 ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
252 buffer.writeBytes(updateMsg);
253
254 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
255 PcepMessage message = null;
bharat saraswalf7364db2015-08-11 13:39:31 +0530256
Bharat saraswal7092b0e2015-08-24 19:40:59 +0530257 message = reader.readFrom(buffer);
bharat saraswalf7364db2015-08-11 13:39:31 +0530258
Bharat saraswal7092b0e2015-08-24 19:40:59 +0530259 Assert.assertTrue("PcepMessage is not instance of PcUpd", (message instanceof PcepUpdateMsg));
260 ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
261 message.writeTo(buf);
262 testupdateMsg = buf.array();
bharat saraswalf7364db2015-08-11 13:39:31 +0530263
Bharat saraswal7092b0e2015-08-24 19:40:59 +0530264 int readLen = buf.writerIndex() - 0;
265 testupdateMsg = new byte[readLen];
266 buf.readBytes(testupdateMsg, 0, readLen);
267
268 Assert.assertArrayEquals("PcUpd messages are not equal", updateMsg, testupdateMsg);
bharat saraswalf7364db2015-08-11 13:39:31 +0530269
270 }
271
Bharat saraswal7092b0e2015-08-24 19:40:59 +0530272 /**
273 * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv,
274 * StatefulLspErrorCodeTlv), ERO objects in PcUpd message.
275 *
276 * @throws PcepParseException when message parsing fails
277 */
bharat saraswalf7364db2015-08-11 13:39:31 +0530278 @Test
279 public void pcepUpdateMsgTest7() throws PcepParseException {
280
bharat saraswalf7364db2015-08-11 13:39:31 +0530281 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x48,
282 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
283 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
284 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object
285 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
286 (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
287 (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
288 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
289 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
290 0x07, 0x10, 0x00, 0x04}; //ERO object
291
292 byte[] testupdateMsg = {0};
293 ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
294 buffer.writeBytes(updateMsg);
295
296 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
297 PcepMessage message = null;
bharat saraswalf7364db2015-08-11 13:39:31 +0530298
Bharat saraswal7092b0e2015-08-24 19:40:59 +0530299 message = reader.readFrom(buffer);
bharat saraswalf7364db2015-08-11 13:39:31 +0530300
Bharat saraswal7092b0e2015-08-24 19:40:59 +0530301 Assert.assertTrue("PcepMessage is not instance of PcUpd", (message instanceof PcepUpdateMsg));
302 ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
303 message.writeTo(buf);
304 testupdateMsg = buf.array();
bharat saraswalf7364db2015-08-11 13:39:31 +0530305
Bharat saraswal7092b0e2015-08-24 19:40:59 +0530306 int readLen = buf.writerIndex() - 0;
307 testupdateMsg = new byte[readLen];
308 buf.readBytes(testupdateMsg, 0, readLen);
309 Assert.assertArrayEquals("PcUpd messages are not equal", updateMsg, testupdateMsg);
bharat saraswalf7364db2015-08-11 13:39:31 +0530310 }
311
Bharat saraswal7092b0e2015-08-24 19:40:59 +0530312 /**
313 * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv,
314 * StatefulLspErrorCodeTlv), ERO (IPv4SubObject) objects in PcUpd message.
315 *
316 * @throws PcepParseException when message parsing fails
317 */
bharat saraswalf7364db2015-08-11 13:39:31 +0530318 @Test
319 public void pcepUpdateMsgTest8() throws PcepParseException {
320
bharat saraswalf7364db2015-08-11 13:39:31 +0530321 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x50,
322 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
323 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
324 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object
325 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
326 (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
327 (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
328 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
329 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
330 0x07, 0x10, 0x00, 0x0c, 0x01, 0x08, 0x11, 0x01, //ERO object
331 0x01, 0x01, 0x04, 0x00 };
332
333 byte[] testupdateMsg = {0};
334 ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
335 buffer.writeBytes(updateMsg);
336
337 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
338 PcepMessage message = null;
bharat saraswalf7364db2015-08-11 13:39:31 +0530339
Bharat saraswal7092b0e2015-08-24 19:40:59 +0530340 message = reader.readFrom(buffer);
bharat saraswalf7364db2015-08-11 13:39:31 +0530341
Bharat saraswal7092b0e2015-08-24 19:40:59 +0530342 Assert.assertTrue("PcepMessage is not instance of PcUpd", (message instanceof PcepUpdateMsg));
343 ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
344 message.writeTo(buf);
345 testupdateMsg = buf.array();
bharat saraswalf7364db2015-08-11 13:39:31 +0530346
Bharat saraswal7092b0e2015-08-24 19:40:59 +0530347 int readLen = buf.writerIndex() - 0;
348 testupdateMsg = new byte[readLen];
349 buf.readBytes(testupdateMsg, 0, readLen);
350
351 Assert.assertArrayEquals("PcUpd messages are not equal", updateMsg, testupdateMsg);
bharat saraswalf7364db2015-08-11 13:39:31 +0530352 }
353
Bharat saraswal7092b0e2015-08-24 19:40:59 +0530354 /**
355 * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv,
356 * StatefulLspErrorCodeTlv), ERO (IPv4SubObject, IPv4SubObject) objects in PcUpd message.
357 *
358 * @throws PcepParseException when message parsing fails
359 */
bharat saraswalf7364db2015-08-11 13:39:31 +0530360 @Test
361 public void pcepUpdateMsgTest9() throws PcepParseException {
362
bharat saraswalf7364db2015-08-11 13:39:31 +0530363 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x58,
364 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
365 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
366 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object
367 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
368 (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
369 (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
370 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
371 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
372 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
373 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
374 0x01, 0x01, 0x04, 0x00 };
375
376 byte[] testupdateMsg = {0};
377 ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
378 buffer.writeBytes(updateMsg);
379
380 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
381 PcepMessage message = null;
bharat saraswalf7364db2015-08-11 13:39:31 +0530382
Bharat saraswal7092b0e2015-08-24 19:40:59 +0530383 message = reader.readFrom(buffer);
bharat saraswalf7364db2015-08-11 13:39:31 +0530384
Bharat saraswal7092b0e2015-08-24 19:40:59 +0530385 Assert.assertTrue("PcepMessage is not instance of PcUpd", (message instanceof PcepUpdateMsg));
386 ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
387 message.writeTo(buf);
388 testupdateMsg = buf.array();
bharat saraswalf7364db2015-08-11 13:39:31 +0530389
Bharat saraswal7092b0e2015-08-24 19:40:59 +0530390 int readLen = buf.writerIndex() - 0;
391 testupdateMsg = new byte[readLen];
392 buf.readBytes(testupdateMsg, 0, readLen);
393
394 Assert.assertArrayEquals("PcUpd messages are not equal", updateMsg, testupdateMsg);
bharat saraswalf7364db2015-08-11 13:39:31 +0530395 }
396
Bharat saraswal7092b0e2015-08-24 19:40:59 +0530397 /**
398 * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv,
399 * StatefulLspErrorCodeTlv), ERO (IPv4SubObject, IPv4SubObject), LSPA objects in PcUpd message.
400 *
401 * @throws PcepParseException when message parsing fails
402 */
bharat saraswalf7364db2015-08-11 13:39:31 +0530403 @Test
404 public void pcepUpdateMsgTest10() throws PcepParseException {
405
bharat saraswalf7364db2015-08-11 13:39:31 +0530406 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x6c,
407 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
408 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
409 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object
410 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
411 (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
412 (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
413 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
414 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
415 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
416 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
417 0x01, 0x01, 0x04, 0x00,
418 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
419 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00 };
420
421 byte[] testupdateMsg = {0};
422 ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
423 buffer.writeBytes(updateMsg);
424
425 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
426 PcepMessage message = null;
bharat saraswalf7364db2015-08-11 13:39:31 +0530427
Bharat saraswal7092b0e2015-08-24 19:40:59 +0530428 message = reader.readFrom(buffer);
bharat saraswalf7364db2015-08-11 13:39:31 +0530429
Bharat saraswal7092b0e2015-08-24 19:40:59 +0530430 Assert.assertTrue("PcepMessage is not instance of PcUpd", (message instanceof PcepUpdateMsg));
431 ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
432 message.writeTo(buf);
433 testupdateMsg = buf.array();
bharat saraswalf7364db2015-08-11 13:39:31 +0530434
Bharat saraswal7092b0e2015-08-24 19:40:59 +0530435 int readLen = buf.writerIndex() - 0;
436 testupdateMsg = new byte[readLen];
437 buf.readBytes(testupdateMsg, 0, readLen);
438
439 Assert.assertArrayEquals("PcUpd messages are not equal", updateMsg, testupdateMsg);
bharat saraswalf7364db2015-08-11 13:39:31 +0530440 }
441
Bharat saraswal7092b0e2015-08-24 19:40:59 +0530442 /**
443 * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv,
444 * StatefulLspErrorCodeTlv), ERO (IPv4SubObject, IPv4SubObject),LSPA, Metric objects in PcUpd message.
445 *
446 * @throws PcepParseException when message parsing fails
447 */
bharat saraswalf7364db2015-08-11 13:39:31 +0530448 @Test
449 public void pcepUpdateMsgTest11() throws PcepParseException {
450
bharat saraswalf7364db2015-08-11 13:39:31 +0530451 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x78,
452 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
453 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
454 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object
455 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
456 (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
457 (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
458 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
459 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
460 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
461 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
462 0x01, 0x01, 0x04, 0x00,
463 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
464 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
465 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
466
467 byte[] testupdateMsg = {0};
468 ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
469 buffer.writeBytes(updateMsg);
470
471 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
472 PcepMessage message = null;
bharat saraswalf7364db2015-08-11 13:39:31 +0530473
Bharat saraswal7092b0e2015-08-24 19:40:59 +0530474 message = reader.readFrom(buffer);
bharat saraswalf7364db2015-08-11 13:39:31 +0530475
Bharat saraswal7092b0e2015-08-24 19:40:59 +0530476 Assert.assertTrue("PcepMessage is not instance of PcUpd", (message instanceof PcepUpdateMsg));
477 ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
478 message.writeTo(buf);
479 testupdateMsg = buf.array();
bharat saraswalf7364db2015-08-11 13:39:31 +0530480
Bharat saraswal7092b0e2015-08-24 19:40:59 +0530481 int readLen = buf.writerIndex() - 0;
482 testupdateMsg = new byte[readLen];
483 buf.readBytes(testupdateMsg, 0, readLen);
484
485 Assert.assertArrayEquals("PcUpd messages are not equal", updateMsg, testupdateMsg);
bharat saraswalf7364db2015-08-11 13:39:31 +0530486 }
487
Bharat saraswal7092b0e2015-08-24 19:40:59 +0530488 /**
489 * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv,
490 * StatefulLspErrorCodeTlv), ERO (IPv4SubObject, IPv4SubObject),LSPA, metric objects in PcUpd message.
491 *
492 * @throws PcepParseException when message parsing fails
493 */
bharat saraswalf7364db2015-08-11 13:39:31 +0530494 @Test
495 public void pcepUpdateMsgTest12() throws PcepParseException {
496
bharat saraswalf7364db2015-08-11 13:39:31 +0530497 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x70,
498 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
499 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object
500 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
501 (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
502 (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
503 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
504 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
505 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
506 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
507 0x01, 0x01, 0x04, 0x00,
508 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
509 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
510 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
511
512 byte[] testupdateMsg = {0};
513 ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
514 buffer.writeBytes(updateMsg);
515
516 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
517 PcepMessage message = null;
bharat saraswalf7364db2015-08-11 13:39:31 +0530518
Bharat saraswal7092b0e2015-08-24 19:40:59 +0530519 message = reader.readFrom(buffer);
bharat saraswalf7364db2015-08-11 13:39:31 +0530520
Bharat saraswal7092b0e2015-08-24 19:40:59 +0530521 Assert.assertTrue("PcepMessage is not instance of PcUpd", (message instanceof PcepUpdateMsg));
522 ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
523 message.writeTo(buf);
524 testupdateMsg = buf.array();
bharat saraswalf7364db2015-08-11 13:39:31 +0530525
Bharat saraswal7092b0e2015-08-24 19:40:59 +0530526 int readLen = buf.writerIndex() - 0;
527 testupdateMsg = new byte[readLen];
528 buf.readBytes(testupdateMsg, 0, readLen);
529
530 Assert.assertArrayEquals("PcUpd messages are not equal", updateMsg, testupdateMsg);
bharat saraswalf7364db2015-08-11 13:39:31 +0530531 }
532
Bharat saraswal7092b0e2015-08-24 19:40:59 +0530533 /**
534 * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv,
535 * StatefulLspErrorCodeTlv), ERO (IPv4SubObject, IPv4SubObject),LSPA, metric objects in PcUpd message.
536 *
537 * @throws PcepParseException when message parsing fails
538 */
bharat saraswalf7364db2015-08-11 13:39:31 +0530539 @Test
540 public void pcepUpdateMsgTest13() throws PcepParseException {
541
bharat saraswalf7364db2015-08-11 13:39:31 +0530542 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x70,
543 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
544 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object
545 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
546 (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
547 (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
548 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
549 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
550 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
551 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
552 0x01, 0x01, 0x04, 0x00,
553 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
554 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
555 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
556
557 byte[] testupdateMsg = {0};
558 ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
559 buffer.writeBytes(updateMsg);
560
561 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
562 PcepMessage message = null;
bharat saraswalf7364db2015-08-11 13:39:31 +0530563
Bharat saraswal7092b0e2015-08-24 19:40:59 +0530564 message = reader.readFrom(buffer);
bharat saraswalf7364db2015-08-11 13:39:31 +0530565
Bharat saraswal7092b0e2015-08-24 19:40:59 +0530566 Assert.assertTrue("PcepMessage is not instance of PcUpd", (message instanceof PcepUpdateMsg));
567 ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
568 message.writeTo(buf);
569 testupdateMsg = buf.array();
bharat saraswalf7364db2015-08-11 13:39:31 +0530570
Bharat saraswal7092b0e2015-08-24 19:40:59 +0530571 int readLen = buf.writerIndex() - 0;
572 testupdateMsg = new byte[readLen];
573 buf.readBytes(testupdateMsg, 0, readLen);
574
575 Assert.assertArrayEquals("PcUpd messages are not equal", updateMsg, testupdateMsg);
bharat saraswalf7364db2015-08-11 13:39:31 +0530576 }
577
Bharat saraswal7092b0e2015-08-24 19:40:59 +0530578 /**
579 * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv),
580 * ERO (IPv4SubObject, IPv4SubObject),LSPA, metric Object objects in PcUpd message.
581 *
582 * @throws PcepParseException when message parsing fails
583 */
bharat saraswalf7364db2015-08-11 13:39:31 +0530584 @Test
585 public void pcepUpdateMsgTest14() throws PcepParseException {
586
bharat saraswalf7364db2015-08-11 13:39:31 +0530587 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x68,
588 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
589 0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x10, 0x03, //LSP object
590 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
591 (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
592 (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
593 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
594 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
595 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
596 0x01, 0x01, 0x04, 0x00,
597 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
598 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
599 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
600
601 byte[] testupdateMsg = {0};
602 ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
603 buffer.writeBytes(updateMsg);
604
605 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
606 PcepMessage message = null;
bharat saraswalf7364db2015-08-11 13:39:31 +0530607
Bharat saraswal7092b0e2015-08-24 19:40:59 +0530608 message = reader.readFrom(buffer);
bharat saraswalf7364db2015-08-11 13:39:31 +0530609
Bharat saraswal7092b0e2015-08-24 19:40:59 +0530610 Assert.assertTrue("PcepMessage is not instance of PcUpd", (message instanceof PcepUpdateMsg));
611 ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
612 message.writeTo(buf);
613 testupdateMsg = buf.array();
bharat saraswalf7364db2015-08-11 13:39:31 +0530614
Bharat saraswal7092b0e2015-08-24 19:40:59 +0530615 int readLen = buf.writerIndex() - 0;
616 testupdateMsg = new byte[readLen];
617 buf.readBytes(testupdateMsg, 0, readLen);
618
619 Assert.assertArrayEquals("PcUpd messages are not equal", updateMsg, testupdateMsg);
bharat saraswalf7364db2015-08-11 13:39:31 +0530620 }
621
Bharat saraswal7092b0e2015-08-24 19:40:59 +0530622 /**
623 * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv),
624 * ERO (IPv4SubObject, IPv4SubObject),LSPA, metric objects in PcUpd message.
625 *
626 * @throws PcepParseException when message parsing fails
627 */
bharat saraswalf7364db2015-08-11 13:39:31 +0530628 @Test
629 public void pcepUpdateMsgTest15() throws PcepParseException {
630
bharat saraswalf7364db2015-08-11 13:39:31 +0530631 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x68,
632 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
633 0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x10, 0x03, //LSP object
634 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
635 (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
636 (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
637 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
638 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
639 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
640 0x01, 0x01, 0x04, 0x00,
641 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
642 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
643 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
644
645 byte[] testupdateMsg = {0};
646 ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
647 buffer.writeBytes(updateMsg);
648
649 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
650 PcepMessage message = null;
bharat saraswalf7364db2015-08-11 13:39:31 +0530651
Bharat saraswal7092b0e2015-08-24 19:40:59 +0530652 message = reader.readFrom(buffer);
bharat saraswalf7364db2015-08-11 13:39:31 +0530653
Bharat saraswal7092b0e2015-08-24 19:40:59 +0530654 Assert.assertTrue("PcepMessage is not instance of PcUpd", (message instanceof PcepUpdateMsg));
655 ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
656 message.writeTo(buf);
657 testupdateMsg = buf.array();
bharat saraswalf7364db2015-08-11 13:39:31 +0530658
Bharat saraswal7092b0e2015-08-24 19:40:59 +0530659 int readLen = buf.writerIndex() - 0;
660 testupdateMsg = new byte[readLen];
661 buf.readBytes(testupdateMsg, 0, readLen);
662
663 Assert.assertArrayEquals("PcUpd messages are not equal", updateMsg, testupdateMsg);
bharat saraswalf7364db2015-08-11 13:39:31 +0530664 }
665
Bharat saraswal7092b0e2015-08-24 19:40:59 +0530666 /**
667 * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv),
668 * ERO (IPv4SubObject, IPv4SubObject),LSPA, metric objects in PcUpd message.
669 *
670 * @throws PcepParseException when message parsing fails
671 */
bharat saraswalf7364db2015-08-11 13:39:31 +0530672 @Test
673 public void pcepUpdateMsgTest16() throws PcepParseException {
674
bharat saraswalf7364db2015-08-11 13:39:31 +0530675 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x60,
676 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
677 0x20, 0x10, 0x00, 0x1C, 0x00, 0x00, 0x10, 0x03, //LSP object
678 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
679 (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
680 (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
681 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
682 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
683 0x01, 0x01, 0x04, 0x00,
684 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
685 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
686 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
687
688 byte[] testupdateMsg = {0};
689 ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
690 buffer.writeBytes(updateMsg);
691
692 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
693 PcepMessage message = null;
bharat saraswalf7364db2015-08-11 13:39:31 +0530694
Bharat saraswal7092b0e2015-08-24 19:40:59 +0530695 message = reader.readFrom(buffer);
bharat saraswalf7364db2015-08-11 13:39:31 +0530696
Bharat saraswal7092b0e2015-08-24 19:40:59 +0530697 Assert.assertTrue("PcepMessage is not instance of PcUpd", (message instanceof PcepUpdateMsg));
698 ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
699 message.writeTo(buf);
700 testupdateMsg = buf.array();
bharat saraswalf7364db2015-08-11 13:39:31 +0530701
Bharat saraswal7092b0e2015-08-24 19:40:59 +0530702 int readLen = buf.writerIndex() - 0;
703 testupdateMsg = new byte[readLen];
704 buf.readBytes(testupdateMsg, 0, readLen);
705
706 Assert.assertArrayEquals("PcUpd messages are not equal", updateMsg, testupdateMsg);
bharat saraswalf7364db2015-08-11 13:39:31 +0530707 }
708
Bharat saraswal7092b0e2015-08-24 19:40:59 +0530709 /**
710 * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv),
711 * ERO (IPv4SubObject, IPv4SubObject),LSPA objects in PcUpd message.
712 *
713 * @throws PcepParseException when message parsing fails
714 */
bharat saraswalf7364db2015-08-11 13:39:31 +0530715 @Test
716 public void pcepUpdateMsgTest17() throws PcepParseException {
717
bharat saraswalf7364db2015-08-11 13:39:31 +0530718 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x54,
719 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
720 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x05, //LSP object
721 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
722 (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
723 (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
724 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
725 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
726 0x01, 0x01, 0x04, 0x00,
727 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
728 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00 };
729
730 byte[] testupdateMsg = {0};
731 ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
732 buffer.writeBytes(updateMsg);
733
734 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
735 PcepMessage message = null;
bharat saraswalf7364db2015-08-11 13:39:31 +0530736
Bharat saraswal7092b0e2015-08-24 19:40:59 +0530737 message = reader.readFrom(buffer);
bharat saraswalf7364db2015-08-11 13:39:31 +0530738
Bharat saraswal7092b0e2015-08-24 19:40:59 +0530739 Assert.assertTrue("PcepMessage is not instance of PcUpd", (message instanceof PcepUpdateMsg));
740 ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
741 message.writeTo(buf);
742 testupdateMsg = buf.array();
bharat saraswalf7364db2015-08-11 13:39:31 +0530743
Bharat saraswal7092b0e2015-08-24 19:40:59 +0530744 int readLen = buf.writerIndex() - 0;
745 testupdateMsg = new byte[readLen];
746 buf.readBytes(testupdateMsg, 0, readLen);
747
748 Assert.assertArrayEquals("PcUpd messages are not equal", updateMsg, testupdateMsg);
bharat saraswalf7364db2015-08-11 13:39:31 +0530749 }
750
Bharat saraswal7092b0e2015-08-24 19:40:59 +0530751 /**
752 * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv),
753 * ERO (IPv4SubObject, IPv4SubObject),Metric objects in PcUpd message.
754 *
755 * @throws PcepParseException when message parsing fails
756 */
bharat saraswalf7364db2015-08-11 13:39:31 +0530757 @Test
758 public void pcepUpdateMsgTest18() throws PcepParseException {
759
bharat saraswalf7364db2015-08-11 13:39:31 +0530760 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x4c,
761 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
762 0x20, 0x10, 0x00, 0x1C, 0x00, 0x00, 0x10, 0x03, //LSP object
763 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
764 (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
765 (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
766 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
767 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
768 0x01, 0x01, 0x04, 0x00,
769 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
770
771 byte[] testupdateMsg = {0};
772 ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
773 buffer.writeBytes(updateMsg);
774
775 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
776 PcepMessage message = null;
bharat saraswalf7364db2015-08-11 13:39:31 +0530777
Bharat saraswal7092b0e2015-08-24 19:40:59 +0530778 message = reader.readFrom(buffer);
bharat saraswalf7364db2015-08-11 13:39:31 +0530779
Bharat saraswal7092b0e2015-08-24 19:40:59 +0530780 Assert.assertTrue("PcepMessage is not instance of PcUpd", (message instanceof PcepUpdateMsg));
781 ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
782 message.writeTo(buf);
783 testupdateMsg = buf.array();
bharat saraswalf7364db2015-08-11 13:39:31 +0530784
Bharat saraswal7092b0e2015-08-24 19:40:59 +0530785 int readLen = buf.writerIndex() - 0;
786 testupdateMsg = new byte[readLen];
787 buf.readBytes(testupdateMsg, 0, readLen);
788
789 Assert.assertArrayEquals("PcUpd messages are not equal", updateMsg, testupdateMsg);
bharat saraswalf7364db2015-08-11 13:39:31 +0530790 }
791
Bharat saraswal7092b0e2015-08-24 19:40:59 +0530792 /**
793 * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv),
794 * ERO (IPv4SubObject, IPv4SubObject),Metric-list objects in PcUpd message.
795 *
796 * @throws PcepParseException when message parsing fails
797 */
bharat saraswalf7364db2015-08-11 13:39:31 +0530798 @Test
799 public void pcepUpdateMsgTest19() throws PcepParseException {
800
bharat saraswalf7364db2015-08-11 13:39:31 +0530801 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x58,
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 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
808 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
809 0x01, 0x01, 0x04, 0x00,
810 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20, //Metric object
811 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01 }; //Metric object
812
813 byte[] testupdateMsg = {0};
814 ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
815 buffer.writeBytes(updateMsg);
816
817 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
818 PcepMessage message = null;
bharat saraswalf7364db2015-08-11 13:39:31 +0530819
Bharat saraswal7092b0e2015-08-24 19:40:59 +0530820 message = reader.readFrom(buffer);
bharat saraswalf7364db2015-08-11 13:39:31 +0530821
Bharat saraswal7092b0e2015-08-24 19:40:59 +0530822 Assert.assertTrue("PcepMessage is not instance of PcUpd", (message instanceof PcepUpdateMsg));
823 ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
824 message.writeTo(buf);
825 testupdateMsg = buf.array();
bharat saraswalf7364db2015-08-11 13:39:31 +0530826
Bharat saraswal7092b0e2015-08-24 19:40:59 +0530827 int readLen = buf.writerIndex() - 0;
828 testupdateMsg = new byte[readLen];
829 buf.readBytes(testupdateMsg, 0, readLen);
830
831 Assert.assertArrayEquals("PcUpd messages are not equal", updateMsg, testupdateMsg);
bharat saraswalf7364db2015-08-11 13:39:31 +0530832 }
833
Bharat saraswal7092b0e2015-08-24 19:40:59 +0530834 /**
835 * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv,
836 * StatefulLspErrorCodeTlv),ERO (IPv4SubObject, IPv4SubObject),LSPA, Bandwidth, Metric objects in PcUpd message.
837 *
838 * @throws PcepParseException when message parsing fails
839 */
bharat saraswalf7364db2015-08-11 13:39:31 +0530840 @Test
841 public void pcepUpdateMsgTest20() throws PcepParseException {
842
bharat saraswalf7364db2015-08-11 13:39:31 +0530843 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x80,
844 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
845 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
846 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object
847 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
848 (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
849 (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
850 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
851 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
852 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
853 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
854 0x01, 0x01, 0x04, 0x00,
855 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
856 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
857 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
858 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
859
860 byte[] testupdateMsg = {0};
861 ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
862 buffer.writeBytes(updateMsg);
863
864 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
865 PcepMessage message = null;
bharat saraswalf7364db2015-08-11 13:39:31 +0530866
Bharat saraswal7092b0e2015-08-24 19:40:59 +0530867 message = reader.readFrom(buffer);
bharat saraswalf7364db2015-08-11 13:39:31 +0530868
Bharat saraswal7092b0e2015-08-24 19:40:59 +0530869 Assert.assertTrue("PcepMessage is not instance of PcUpd", (message instanceof PcepUpdateMsg));
870 ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
871 message.writeTo(buf);
872 testupdateMsg = buf.array();
bharat saraswalf7364db2015-08-11 13:39:31 +0530873
Bharat saraswal7092b0e2015-08-24 19:40:59 +0530874 int readLen = buf.writerIndex() - 0;
875 testupdateMsg = new byte[readLen];
876 buf.readBytes(testupdateMsg, 0, readLen);
877
878 Assert.assertArrayEquals("PcUpd messages are not equal", updateMsg, testupdateMsg);
bharat saraswalf7364db2015-08-11 13:39:31 +0530879 }
880
Bharat saraswal7092b0e2015-08-24 19:40:59 +0530881 /**
882 * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv),
883 * ERO (IPv4SubObject, IPv4SubObject), Bandwidth objects in PcUpd message.
884 *
885 * @throws PcepParseException when message parsing fails
886 */
bharat saraswalf7364db2015-08-11 13:39:31 +0530887 @Test
888 public void pcepUpdateMsgTest21() throws PcepParseException {
889
bharat saraswalf7364db2015-08-11 13:39:31 +0530890 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x48,
891 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
892 0x20, 0x10, 0x00, 0x1C, 0x00, 0x00, 0x10, 0x03, //LSP object
893 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
894 (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
895 (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
896 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
897 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
898 0x01, 0x01, 0x04, 0x00,
899 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00 }; //Bandwidth object
900
901 byte[] testupdateMsg = {0};
902 ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
903 buffer.writeBytes(updateMsg);
904
905 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
906 PcepMessage message = null;
bharat saraswalf7364db2015-08-11 13:39:31 +0530907
Bharat saraswal7092b0e2015-08-24 19:40:59 +0530908 message = reader.readFrom(buffer);
bharat saraswalf7364db2015-08-11 13:39:31 +0530909
Bharat saraswal7092b0e2015-08-24 19:40:59 +0530910 Assert.assertTrue("PcepMessage is not instance of PcUpd", (message instanceof PcepUpdateMsg));
911 ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
912 message.writeTo(buf);
913 testupdateMsg = buf.array();
bharat saraswalf7364db2015-08-11 13:39:31 +0530914
Bharat saraswal7092b0e2015-08-24 19:40:59 +0530915 int readLen = buf.writerIndex() - 0;
916 testupdateMsg = new byte[readLen];
917 buf.readBytes(testupdateMsg, 0, readLen);
918
919 Assert.assertArrayEquals("PcUpd messages are not equal", updateMsg, testupdateMsg);
bharat saraswalf7364db2015-08-11 13:39:31 +0530920 }
921
Bharat saraswal7092b0e2015-08-24 19:40:59 +0530922 /**
923 * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv),
924 * ERO (IPv4SubObject, IPv4SubObject), LSPA, Bandwidth objects in PcUpd message.
925 *
926 * @throws PcepParseException when message parsing fails
927 */
bharat saraswalf7364db2015-08-11 13:39:31 +0530928 @Test
929 public void pcepUpdateMsgTest22() throws PcepParseException {
930
bharat saraswalf7364db2015-08-11 13:39:31 +0530931 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x5C,
932 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
933 0x20, 0x10, 0x00, 0x1C, 0x00, 0x00, 0x10, 0x03, //LSP object
934 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
935 (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
936 (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
937 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
938 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
939 0x01, 0x01, 0x04, 0x00,
940 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
941 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
942 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00 }; //Bandwidth object
943
944 byte[] testupdateMsg = {0};
945 ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
946 buffer.writeBytes(updateMsg);
947
948 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
949 PcepMessage message = null;
bharat saraswalf7364db2015-08-11 13:39:31 +0530950
Bharat saraswal7092b0e2015-08-24 19:40:59 +0530951 message = reader.readFrom(buffer);
bharat saraswalf7364db2015-08-11 13:39:31 +0530952
Bharat saraswal7092b0e2015-08-24 19:40:59 +0530953 Assert.assertTrue("PcepMessage is not instance of PcUpd", (message instanceof PcepUpdateMsg));
954 ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
955 message.writeTo(buf);
956 testupdateMsg = buf.array();
bharat saraswalf7364db2015-08-11 13:39:31 +0530957
Bharat saraswal7092b0e2015-08-24 19:40:59 +0530958 int readLen = buf.writerIndex() - 0;
959 testupdateMsg = new byte[readLen];
960 buf.readBytes(testupdateMsg, 0, readLen);
961
962 Assert.assertArrayEquals("PcUpd messages are not equal", updateMsg, testupdateMsg);
bharat saraswalf7364db2015-08-11 13:39:31 +0530963 }
964
Bharat saraswal7092b0e2015-08-24 19:40:59 +0530965 /**
966 * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv),
967 * ERO (IPv4SubObject, IPv4SubObject), LSPA, Bandwidth, Metric objects in PcUpd message.
968 *
969 * @throws PcepParseException when message parsing fails
970 */
bharat saraswalf7364db2015-08-11 13:39:31 +0530971 @Test
972 public void pcepUpdateMsgTest23() throws PcepParseException {
973
bharat saraswalf7364db2015-08-11 13:39:31 +0530974 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x68,
975 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
976 0x20, 0x10, 0x00, 0x1C, 0x00, 0x00, 0x10, 0x03, //LSP object
977 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
978 (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
979 (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
980 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
981 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
982 0x01, 0x01, 0x04, 0x00,
983 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
984 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
985 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
986 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
987
988 byte[] testupdateMsg = {0};
989 ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
990 buffer.writeBytes(updateMsg);
991
992 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
993 PcepMessage message = null;
bharat saraswalf7364db2015-08-11 13:39:31 +0530994
Bharat saraswal7092b0e2015-08-24 19:40:59 +0530995 message = reader.readFrom(buffer);
bharat saraswalf7364db2015-08-11 13:39:31 +0530996
Bharat saraswal7092b0e2015-08-24 19:40:59 +0530997 Assert.assertTrue("PcepMessage is not instance of PcUpd", (message instanceof PcepUpdateMsg));
998 ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
999 message.writeTo(buf);
1000 testupdateMsg = buf.array();
bharat saraswalf7364db2015-08-11 13:39:31 +05301001
Bharat saraswal7092b0e2015-08-24 19:40:59 +05301002 int readLen = buf.writerIndex() - 0;
1003 testupdateMsg = new byte[readLen];
1004 buf.readBytes(testupdateMsg, 0, readLen);
1005
1006 Assert.assertArrayEquals("PcUpd messages are not equal", updateMsg, testupdateMsg);
bharat saraswalf7364db2015-08-11 13:39:31 +05301007 }
1008
Bharat saraswal7092b0e2015-08-24 19:40:59 +05301009 /**
1010 * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv)
1011 * ERO (IPv4SubObject, IPv4SubObject), LSPA, Bandwidth, Metric objects in PcUpd message.
1012 *
1013 * @throws PcepParseException when message parsing fails
1014 */
bharat saraswalf7364db2015-08-11 13:39:31 +05301015 @Test
1016 public void pcepUpdateMsgTest24() throws PcepParseException {
1017
bharat saraswalf7364db2015-08-11 13:39:31 +05301018 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x70,
1019 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
1020 0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x10, 0x03, //LSP object
1021 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
1022 (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
1023 (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
1024 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
1025 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
1026 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
1027 0x01, 0x01, 0x04, 0x00,
1028 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
1029 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
1030 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
1031 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
1032
1033 byte[] testupdateMsg = {0};
1034 ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
1035 buffer.writeBytes(updateMsg);
1036
1037 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
1038 PcepMessage message = null;
bharat saraswalf7364db2015-08-11 13:39:31 +05301039
Bharat saraswal7092b0e2015-08-24 19:40:59 +05301040 message = reader.readFrom(buffer);
bharat saraswalf7364db2015-08-11 13:39:31 +05301041
Bharat saraswal7092b0e2015-08-24 19:40:59 +05301042 Assert.assertTrue("PcepMessage is not instance of PcUpd", (message instanceof PcepUpdateMsg));
1043 ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
1044 message.writeTo(buf);
1045 testupdateMsg = buf.array();
bharat saraswalf7364db2015-08-11 13:39:31 +05301046
Bharat saraswal7092b0e2015-08-24 19:40:59 +05301047 int readLen = buf.writerIndex() - 0;
1048 testupdateMsg = new byte[readLen];
1049 buf.readBytes(testupdateMsg, 0, readLen);
1050
1051 Assert.assertArrayEquals("PcUpd messages are not equal", updateMsg, testupdateMsg);
bharat saraswalf7364db2015-08-11 13:39:31 +05301052 }
1053
Bharat saraswal7092b0e2015-08-24 19:40:59 +05301054 /**
1055 * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv)
1056 * ERO (IPv4SubObject, IPv4SubObject), LSPA, Bandwidth, Metric objects in PcUpd message.
1057 *
1058 * @throws PcepParseException when message parsing fails
1059 */
bharat saraswalf7364db2015-08-11 13:39:31 +05301060 @Test
1061 public void pcepUpdateMsgTest25() throws PcepParseException {
1062
bharat saraswalf7364db2015-08-11 13:39:31 +05301063 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x70,
1064 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
1065 0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x10, 0x03, //LSP object
1066 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
1067 (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
1068 (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
1069 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
1070 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
1071 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
1072 0x01, 0x01, 0x04, 0x00,
1073 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
1074 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
1075 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
1076 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
1077
1078 byte[] testupdateMsg = {0};
1079 ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
1080 buffer.writeBytes(updateMsg);
1081
1082 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
1083 PcepMessage message = null;
bharat saraswalf7364db2015-08-11 13:39:31 +05301084
Bharat saraswal7092b0e2015-08-24 19:40:59 +05301085 message = reader.readFrom(buffer);
bharat saraswalf7364db2015-08-11 13:39:31 +05301086
Bharat saraswal7092b0e2015-08-24 19:40:59 +05301087 Assert.assertTrue("PcepMessage is not instance of PcUpd", (message instanceof PcepUpdateMsg));
1088 ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
1089 message.writeTo(buf);
1090 testupdateMsg = buf.array();
bharat saraswalf7364db2015-08-11 13:39:31 +05301091
Bharat saraswal7092b0e2015-08-24 19:40:59 +05301092 int readLen = buf.writerIndex() - 0;
1093 testupdateMsg = new byte[readLen];
1094 buf.readBytes(testupdateMsg, 0, readLen);
1095
1096 Assert.assertArrayEquals("PcUpd messages are not equal", updateMsg, testupdateMsg);
bharat saraswalf7364db2015-08-11 13:39:31 +05301097 }
1098
Bharat saraswal7092b0e2015-08-24 19:40:59 +05301099 /**
1100 * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv,
1101 * StatefulLspErrorCodeTlv) ERO (IPv4SubObject, IPv4SubObject), LSPA, Bandwidth,
1102 * Metric objects in PcUpd message.
1103 *
1104 * @throws PcepParseException when message parsing fails
1105 */
bharat saraswalf7364db2015-08-11 13:39:31 +05301106 @Test
1107 public void pcepUpdateMsgTest26() throws PcepParseException {
1108
bharat saraswalf7364db2015-08-11 13:39:31 +05301109 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x78,
1110 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
1111 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object
1112 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
1113 (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
1114 (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
1115 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
1116 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
1117 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
1118 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
1119 0x01, 0x01, 0x04, 0x00,
1120 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
1121 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
1122 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
1123 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
1124
1125 byte[] testupdateMsg = {0};
1126 ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
1127 buffer.writeBytes(updateMsg);
1128
1129 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
1130 PcepMessage message = null;
bharat saraswalf7364db2015-08-11 13:39:31 +05301131
Bharat saraswal7092b0e2015-08-24 19:40:59 +05301132 message = reader.readFrom(buffer);
1133 Assert.assertTrue("PcepMessage is not instance of PcUpd", (message instanceof PcepUpdateMsg));
1134 ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
1135 message.writeTo(buf);
1136 testupdateMsg = buf.array();
bharat saraswalf7364db2015-08-11 13:39:31 +05301137
Bharat saraswal7092b0e2015-08-24 19:40:59 +05301138 int readLen = buf.writerIndex() - 0;
1139 testupdateMsg = new byte[readLen];
1140 buf.readBytes(testupdateMsg, 0, readLen);
bharat saraswalf7364db2015-08-11 13:39:31 +05301141
Bharat saraswal7092b0e2015-08-24 19:40:59 +05301142 Assert.assertArrayEquals("PcUpd messages are not equal", updateMsg, testupdateMsg);
bharat saraswalf7364db2015-08-11 13:39:31 +05301143 }
1144
Bharat saraswal7092b0e2015-08-24 19:40:59 +05301145 /**
1146 * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv,
1147 * StatefulLspErrorCodeTlv) ERO (IPv4SubObject, IPv4SubObject), LSPA, Bandwidth,
1148 * Metric objects in PcUpd message.
1149 *
1150 * @throws PcepParseException when message parsing fails
1151 */
bharat saraswalf7364db2015-08-11 13:39:31 +05301152 @Test
1153 public void pcepUpdateMsgTest27() throws PcepParseException {
1154
bharat saraswalf7364db2015-08-11 13:39:31 +05301155 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x78,
1156 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
1157 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object
1158 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
1159 (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
1160 (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
1161 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
1162 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
1163 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
1164 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
1165 0x01, 0x01, 0x04, 0x00,
1166 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
1167 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
1168 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
1169 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
1170
1171 byte[] testupdateMsg = {0};
1172 ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
1173 buffer.writeBytes(updateMsg);
1174
1175 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
1176 PcepMessage message = null;
bharat saraswalf7364db2015-08-11 13:39:31 +05301177
Bharat saraswal7092b0e2015-08-24 19:40:59 +05301178 message = reader.readFrom(buffer);
bharat saraswalf7364db2015-08-11 13:39:31 +05301179
Bharat saraswal7092b0e2015-08-24 19:40:59 +05301180 Assert.assertTrue("PcepMessage is not instance of PcUpd", (message instanceof PcepUpdateMsg));
1181 ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
1182 message.writeTo(buf);
1183 testupdateMsg = buf.array();
bharat saraswalf7364db2015-08-11 13:39:31 +05301184
Bharat saraswal7092b0e2015-08-24 19:40:59 +05301185 int readLen = buf.writerIndex() - 0;
1186 testupdateMsg = new byte[readLen];
1187 buf.readBytes(testupdateMsg, 0, readLen);
1188
1189 Assert.assertArrayEquals("PcUpd messages are not equal", updateMsg, testupdateMsg);
bharat saraswalf7364db2015-08-11 13:39:31 +05301190 }
1191
Bharat saraswal7092b0e2015-08-24 19:40:59 +05301192 /**
1193 * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv,
1194 * SymbolicPathNameTlv, StatefulLspErrorCodeTlv), ERO (IPv4SubObject, IPv4SubObject),
1195 * LSPA, Bandwidth, Metric objects in PcUpd message.
1196 *
1197 * @throws PcepParseException when message parsing fails
1198 */
bharat saraswalf7364db2015-08-11 13:39:31 +05301199 @Test
1200 public void pcepUpdateMsgTest28() throws PcepParseException {
1201
bharat saraswalf7364db2015-08-11 13:39:31 +05301202 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x80,
1203 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
1204 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
1205 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object
1206 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
1207 (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
1208 (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
1209 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
1210 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
1211 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
1212 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
1213 0x01, 0x01, 0x04, 0x00,
1214 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
1215 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
1216 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
1217 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
1218
1219 byte[] testupdateMsg = {0};
1220 ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
1221 buffer.writeBytes(updateMsg);
1222
1223 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
1224 PcepMessage message = null;
bharat saraswalf7364db2015-08-11 13:39:31 +05301225
Bharat saraswal7092b0e2015-08-24 19:40:59 +05301226 message = reader.readFrom(buffer);
bharat saraswalf7364db2015-08-11 13:39:31 +05301227
Bharat saraswal7092b0e2015-08-24 19:40:59 +05301228 Assert.assertTrue("PcepMessage is not instance of PcUpd", (message instanceof PcepUpdateMsg));
1229 ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
1230 message.writeTo(buf);
1231 testupdateMsg = buf.array();
bharat saraswalf7364db2015-08-11 13:39:31 +05301232
Bharat saraswal7092b0e2015-08-24 19:40:59 +05301233 int readLen = buf.writerIndex() - 0;
1234 testupdateMsg = new byte[readLen];
1235 buf.readBytes(testupdateMsg, 0, readLen);
1236
1237 Assert.assertArrayEquals("PcUpd messages are not equal", updateMsg, testupdateMsg);
bharat saraswalf7364db2015-08-11 13:39:31 +05301238 }
1239
Bharat saraswal7092b0e2015-08-24 19:40:59 +05301240 /**
1241 * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv),
1242 * ERO (IPv4SubObject, IPv4SubObject), LSPA, Bandwidth, Metric objects in PcUpd message.
1243 *
1244 * @throws PcepParseException when message parsing fails
1245 */
bharat saraswalf7364db2015-08-11 13:39:31 +05301246 @Test
1247 public void pcepUpdateMsgTest29() throws PcepParseException {
1248
bharat saraswalf7364db2015-08-11 13:39:31 +05301249 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x68,
1250 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
1251 0x20, 0x10, 0x00, 0x1C, 0x00, 0x00, 0x10, 0x03, //LSP object
1252 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
1253 (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
1254 (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
1255 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
1256 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
1257 0x01, 0x01, 0x04, 0x00,
1258 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
1259 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
1260 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
1261 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
1262
1263 byte[] testupdateMsg = {0};
1264 ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
1265 buffer.writeBytes(updateMsg);
1266
1267 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
1268 PcepMessage message = null;
bharat saraswalf7364db2015-08-11 13:39:31 +05301269
Bharat saraswal7092b0e2015-08-24 19:40:59 +05301270 message = reader.readFrom(buffer);
bharat saraswalf7364db2015-08-11 13:39:31 +05301271
Bharat saraswal7092b0e2015-08-24 19:40:59 +05301272 Assert.assertTrue("PcepMessage is not instance of PcUpd", (message instanceof PcepUpdateMsg));
1273 ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
1274 message.writeTo(buf);
1275 testupdateMsg = buf.array();
bharat saraswalf7364db2015-08-11 13:39:31 +05301276
Bharat saraswal7092b0e2015-08-24 19:40:59 +05301277 int readLen = buf.writerIndex() - 0;
1278 testupdateMsg = new byte[readLen];
1279 buf.readBytes(testupdateMsg, 0, readLen);
1280
1281 Assert.assertArrayEquals("PcUpd messages are not equal", updateMsg, testupdateMsg);
bharat saraswalf7364db2015-08-11 13:39:31 +05301282 }
1283
Bharat saraswal7092b0e2015-08-24 19:40:59 +05301284 /**
1285 * This test case checks for SRP, LSP,
1286 * ERO (IPv4SubObject, IPv4SubObject), LSPA, Bandwidth, Metric objects in PcUpd message.
1287 *
1288 * @throws PcepParseException when message parsing fails
1289 */
bharat saraswalf7364db2015-08-11 13:39:31 +05301290 @Test
1291 public void pcepUpdateMsgTest30() throws PcepParseException {
1292
bharat saraswalf7364db2015-08-11 13:39:31 +05301293 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x54,
1294 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
1295 0x20, 0x10, 0x00, 0x08, 0x00, 0x00, 0x10, 0x03, //LSP object
1296 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
1297 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
1298 0x01, 0x01, 0x04, 0x00,
1299 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
1300 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
1301 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
1302 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20}; //Metric object
1303
1304 byte[] testupdateMsg = {0};
1305 ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
1306 buffer.writeBytes(updateMsg);
1307
1308 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
1309 PcepMessage message = null;
bharat saraswalf7364db2015-08-11 13:39:31 +05301310
Bharat saraswal7092b0e2015-08-24 19:40:59 +05301311 message = reader.readFrom(buffer);
bharat saraswalf7364db2015-08-11 13:39:31 +05301312
Bharat saraswal7092b0e2015-08-24 19:40:59 +05301313 Assert.assertTrue("PcepMessage is not instance of PcUpd", (message instanceof PcepUpdateMsg));
1314 ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
1315 message.writeTo(buf);
1316 testupdateMsg = buf.array();
bharat saraswalf7364db2015-08-11 13:39:31 +05301317
Bharat saraswal7092b0e2015-08-24 19:40:59 +05301318 int readLen = buf.writerIndex() - 0;
1319 testupdateMsg = new byte[readLen];
1320 buf.readBytes(testupdateMsg, 0, readLen);
1321
1322 Assert.assertArrayEquals("PcUpd messages are not equal", updateMsg, testupdateMsg);
bharat saraswalf7364db2015-08-11 13:39:31 +05301323 }
1324
Bharat saraswal7092b0e2015-08-24 19:40:59 +05301325 /**
1326 * This test case checks for SRP, LSP (StatefulLspErrorCodeTlv),
1327 * ERO (IPv4SubObject, IPv4SubObject), LSPA, Bandwidth, Metric objects in PcUpd message.
1328 *
1329 * @throws PcepParseException when message parsing fails
1330 */
bharat saraswalf7364db2015-08-11 13:39:31 +05301331 @Test
1332 public void pcepUpdateMsgTest31() throws PcepParseException {
1333
bharat saraswalf7364db2015-08-11 13:39:31 +05301334 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x5c,
1335 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
1336 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
1337 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
1338 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
1339 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
1340 0x01, 0x01, 0x04, 0x00,
1341 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
1342 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
1343 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
1344 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
1345
1346 byte[] testupdateMsg = {0};
1347 ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
1348 buffer.writeBytes(updateMsg);
1349
1350 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
1351 PcepMessage message = null;
bharat saraswalf7364db2015-08-11 13:39:31 +05301352
Bharat saraswal7092b0e2015-08-24 19:40:59 +05301353 message = reader.readFrom(buffer);
bharat saraswalf7364db2015-08-11 13:39:31 +05301354
Bharat saraswal7092b0e2015-08-24 19:40:59 +05301355 Assert.assertTrue("PcepMessage is not instance of PcUpd", (message instanceof PcepUpdateMsg));
1356 ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
1357 message.writeTo(buf);
1358 testupdateMsg = buf.array();
bharat saraswalf7364db2015-08-11 13:39:31 +05301359
Bharat saraswal7092b0e2015-08-24 19:40:59 +05301360 int readLen = buf.writerIndex() - 0;
1361 testupdateMsg = new byte[readLen];
1362 buf.readBytes(testupdateMsg, 0, readLen);
1363
1364 Assert.assertArrayEquals("PcUpd messages are not equal", updateMsg, testupdateMsg);
bharat saraswalf7364db2015-08-11 13:39:31 +05301365 }
1366
Bharat saraswal7092b0e2015-08-24 19:40:59 +05301367 /**
1368 * This test case checks for SRP, LSP,
1369 * ERO (IPv4SubObject, IPv4SubObject), LSPA, Bandwidth, Metric objects in PcUpd message.
1370 *
1371 * @throws PcepParseException when message parsing fails
1372 */
bharat saraswalf7364db2015-08-11 13:39:31 +05301373 @Test
1374 public void pcepUpdateMsgTest32() throws PcepParseException {
1375
bharat saraswalf7364db2015-08-11 13:39:31 +05301376 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x54,
1377 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
1378 0x20, 0x10, 0x00, 0x8, 0x00, 0x00, 0x10, 0x03, //LSP object
1379 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
1380 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
1381 0x01, 0x01, 0x04, 0x00,
1382 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
1383 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
1384 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
1385 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
1386
1387 byte[] testupdateMsg = {0};
1388 ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
1389 buffer.writeBytes(updateMsg);
1390
1391 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
1392 PcepMessage message = null;
bharat saraswalf7364db2015-08-11 13:39:31 +05301393
Bharat saraswal7092b0e2015-08-24 19:40:59 +05301394 message = reader.readFrom(buffer);
bharat saraswalf7364db2015-08-11 13:39:31 +05301395
Bharat saraswal7092b0e2015-08-24 19:40:59 +05301396 Assert.assertTrue("PcepMessage is not instance of PcUpd", (message instanceof PcepUpdateMsg));
1397 ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
1398 message.writeTo(buf);
1399 testupdateMsg = buf.array();
bharat saraswalf7364db2015-08-11 13:39:31 +05301400
Bharat saraswal7092b0e2015-08-24 19:40:59 +05301401 int readLen = buf.writerIndex() - 0;
1402 testupdateMsg = new byte[readLen];
1403 buf.readBytes(testupdateMsg, 0, readLen);
1404
1405 Assert.assertArrayEquals("PcUpd messages are not equal", updateMsg, testupdateMsg);
bharat saraswalf7364db2015-08-11 13:39:31 +05301406 }
1407
Bharat saraswal7092b0e2015-08-24 19:40:59 +05301408 /**
1409 * This test case checks for SRP, LSP (SymbolicPathNameTlv),
1410 * ERO (IPv4SubObject, IPv4SubObject), LSPA, Bandwidth, Metric objects in PcUpd message.
1411 *
1412 * @throws PcepParseException when message parsing fails
1413 */
bharat saraswalf7364db2015-08-11 13:39:31 +05301414 @Test
1415 public void pcepUpdateMsgTest33() throws PcepParseException {
1416
bharat saraswalf7364db2015-08-11 13:39:31 +05301417 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x5c,
1418 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
1419 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
1420 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
1421 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
1422 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
1423 0x01, 0x01, 0x04, 0x00,
1424 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
1425 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
1426 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
1427 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
1428
1429 byte[] testupdateMsg = {0};
1430 ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
1431 buffer.writeBytes(updateMsg);
1432
1433 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
1434 PcepMessage message = null;
bharat saraswalf7364db2015-08-11 13:39:31 +05301435
Bharat saraswal7092b0e2015-08-24 19:40:59 +05301436 message = reader.readFrom(buffer);
bharat saraswalf7364db2015-08-11 13:39:31 +05301437
Bharat saraswal7092b0e2015-08-24 19:40:59 +05301438 Assert.assertTrue("PcepMessage is not instance of PcUpd", (message instanceof PcepUpdateMsg));
1439 ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
1440 message.writeTo(buf);
1441 testupdateMsg = buf.array();
bharat saraswalf7364db2015-08-11 13:39:31 +05301442
Bharat saraswal7092b0e2015-08-24 19:40:59 +05301443 int readLen = buf.writerIndex() - 0;
1444 testupdateMsg = new byte[readLen];
1445 buf.readBytes(testupdateMsg, 0, readLen);
1446
1447 Assert.assertArrayEquals("PcUpd messages are not equal", updateMsg, testupdateMsg);
bharat saraswalf7364db2015-08-11 13:39:31 +05301448 }
1449
Bharat saraswal7092b0e2015-08-24 19:40:59 +05301450 /**
1451 * This test case checks for SRP, LSP (SymbolicPathNameTlv, SymbolicPathNameTlv),
1452 * ERO (IPv4SubObject, IPv4SubObject), LSPA, Bandwidth, Metric objects in PcUpd message.
1453 *
1454 * @throws PcepParseException when message parsing fails
1455 */
bharat saraswalf7364db2015-08-11 13:39:31 +05301456 @Test
1457 public void pcepUpdateMsgTest34() throws PcepParseException {
1458
bharat saraswalf7364db2015-08-11 13:39:31 +05301459 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x64,
1460 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
1461 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
1462 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
1463 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
1464 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
1465 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
1466 0x01, 0x01, 0x04, 0x00,
1467 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
1468 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
1469 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
1470 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
1471
1472 byte[] testupdateMsg = {0};
1473 ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
1474 buffer.writeBytes(updateMsg);
1475
1476 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
1477 PcepMessage message = null;
bharat saraswalf7364db2015-08-11 13:39:31 +05301478
Bharat saraswal7092b0e2015-08-24 19:40:59 +05301479 message = reader.readFrom(buffer);
bharat saraswalf7364db2015-08-11 13:39:31 +05301480
Bharat saraswal7092b0e2015-08-24 19:40:59 +05301481 Assert.assertTrue("PcepMessage is not instance of PcUpd", (message instanceof PcepUpdateMsg));
1482 ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
1483 message.writeTo(buf);
1484 testupdateMsg = buf.array();
bharat saraswalf7364db2015-08-11 13:39:31 +05301485
Bharat saraswal7092b0e2015-08-24 19:40:59 +05301486 int readLen = buf.writerIndex() - 0;
1487 testupdateMsg = new byte[readLen];
1488 buf.readBytes(testupdateMsg, 0, readLen);
1489
1490 Assert.assertArrayEquals("PcUpd messages are not equal", updateMsg, testupdateMsg);
bharat saraswalf7364db2015-08-11 13:39:31 +05301491 }
1492}