Bharat saraswal
Committed by Gerrit Code Review

PcepUpdateMsg UT updated for adding javadoc, remove log and if check.

Change-Id: I2604ba9e9ba481e5535043fdcd8225be4acc0ee4
...@@ -17,9 +17,7 @@ package org.onosproject.pcepio; ...@@ -17,9 +17,7 @@ package org.onosproject.pcepio;
17 17
18 import org.jboss.netty.buffer.ChannelBuffer; 18 import org.jboss.netty.buffer.ChannelBuffer;
19 import org.jboss.netty.buffer.ChannelBuffers; 19 import org.jboss.netty.buffer.ChannelBuffers;
20 -import org.junit.After;
21 import org.junit.Assert; 20 import org.junit.Assert;
22 -import org.junit.Before;
23 import org.junit.Test; 21 import org.junit.Test;
24 import org.onosproject.pcepio.exceptions.PcepParseException; 22 import org.onosproject.pcepio.exceptions.PcepParseException;
25 import org.onosproject.pcepio.protocol.PcepFactories; 23 import org.onosproject.pcepio.protocol.PcepFactories;
...@@ -27,27 +25,15 @@ import org.onosproject.pcepio.protocol.PcepMessage; ...@@ -27,27 +25,15 @@ import org.onosproject.pcepio.protocol.PcepMessage;
27 import org.onosproject.pcepio.protocol.PcepMessageReader; 25 import org.onosproject.pcepio.protocol.PcepMessageReader;
28 import org.onosproject.pcepio.protocol.PcepUpdateMsg; 26 import org.onosproject.pcepio.protocol.PcepUpdateMsg;
29 27
30 -import java.util.Arrays;
31 -
32 -import org.slf4j.Logger;
33 -import org.slf4j.LoggerFactory;
34 -
35 public class PcepUpdateMsgTest { 28 public class PcepUpdateMsgTest {
36 - 29 + /**
37 - protected static final Logger log = LoggerFactory.getLogger(PcepUpdateMsgTest.class); 30 + * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv), ERO in PcUpd message.
38 - 31 + *
39 - @Before 32 + * @throws PcepParseException when message paring fails
40 - public void startUp() { 33 + */
41 - }
42 -
43 - @After
44 - public void tearDown() {
45 -
46 - }
47 -
48 @Test 34 @Test
49 public void pcepUpdateMsgTest1() throws PcepParseException { 35 public void pcepUpdateMsgTest1() throws PcepParseException {
50 - //Srp, Lsp (StatefulIPv4LspIdentidiersTlv), Ero. 36 +
51 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x30, 37 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x30,
52 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object 38 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
53 0x20, 0x10, 0x00, 0x1C, 0x00, 0x00, 0x10, 0x03, //LSP object 39 0x20, 0x10, 0x00, 0x1C, 0x00, 0x00, 0x10, 0x03, //LSP object
...@@ -61,41 +47,30 @@ public class PcepUpdateMsgTest { ...@@ -61,41 +47,30 @@ public class PcepUpdateMsgTest {
61 47
62 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); 48 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
63 PcepMessage message = null; 49 PcepMessage message = null;
64 - try { 50 +
65 message = reader.readFrom(buffer); 51 message = reader.readFrom(buffer);
66 - } catch (PcepParseException e) {
67 - e.printStackTrace();
68 - }
69 52
70 - if (message instanceof PcepUpdateMsg) { 53 + Assert.assertTrue("PcepMessage is not instance of PcUpd", (message instanceof PcepUpdateMsg));
71 ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); 54 ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
72 message.writeTo(buf); 55 message.writeTo(buf);
73 testupdateMsg = buf.array(); 56 testupdateMsg = buf.array();
74 57
75 - int iReadLen = buf.writerIndex() - 0; 58 + int readLen = buf.writerIndex() - 0;
76 - testupdateMsg = new byte[iReadLen]; 59 + testupdateMsg = new byte[readLen];
77 - buf.readBytes(testupdateMsg, 0, iReadLen); 60 + buf.readBytes(testupdateMsg, 0, readLen);
78 -
79 - if (Arrays.equals(updateMsg, testupdateMsg)) {
80 - Assert.assertArrayEquals(updateMsg, testupdateMsg);
81 - log.debug("updateMsg are equal :" + updateMsg);
82 - } else {
83 - Assert.fail("test case failed");
84 - log.debug("not equal");
85 - }
86 - } else {
87 - Assert.fail("test case failed");
88 - log.debug("not equal");
89 - }
90 61
62 + Assert.assertArrayEquals("PcUpd messages are not equal", updateMsg, testupdateMsg);
91 } 63 }
92 64
65 + /**
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 + */
93 @Test 71 @Test
94 public void pcepUpdateMsgTest2() throws PcepParseException { 72 public void pcepUpdateMsgTest2() throws PcepParseException {
95 73
96 - /* Srp(SymbolicPathNameTlv), Lsp (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv,
97 - * StatefulLspErrorCodeTlv), Ero, Lspa, Metric-list.
98 - */
99 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x94, 74 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x94,
100 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object 75 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
101 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv 76 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
...@@ -119,41 +94,29 @@ public class PcepUpdateMsgTest { ...@@ -119,41 +94,29 @@ public class PcepUpdateMsgTest {
119 94
120 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); 95 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
121 PcepMessage message = null; 96 PcepMessage message = null;
122 - try {
123 - message = reader.readFrom(buffer);
124 - } catch (PcepParseException e) {
125 - e.printStackTrace();
126 - }
127 97
128 - if (message instanceof PcepUpdateMsg) { 98 + message = reader.readFrom(buffer);
99 + Assert.assertTrue("PcepMessage is not instance of PcUpd", (message instanceof PcepUpdateMsg));
129 ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); 100 ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
130 message.writeTo(buf); 101 message.writeTo(buf);
131 testupdateMsg = buf.array(); 102 testupdateMsg = buf.array();
132 103
133 - int iReadLen = buf.writerIndex() - 0; 104 + int readLen = buf.writerIndex() - 0;
134 - testupdateMsg = new byte[iReadLen]; 105 + testupdateMsg = new byte[readLen];
135 - buf.readBytes(testupdateMsg, 0, iReadLen); 106 + buf.readBytes(testupdateMsg, 0, readLen);
136 -
137 - if (Arrays.equals(updateMsg, testupdateMsg)) {
138 - Assert.assertArrayEquals(updateMsg, testupdateMsg);
139 - log.debug("updateMsg are equal :" + updateMsg);
140 - } else {
141 - Assert.fail("test case failed");
142 - log.debug("not equal");
143 - }
144 - } else {
145 - Assert.fail("test case failed");
146 - log.debug("not equal");
147 - }
148 107
108 + Assert.assertArrayEquals("PcUpd messages are not equal", updateMsg, testupdateMsg);
149 } 109 }
150 110
151 - 111 + /**
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 + */
152 @Test 117 @Test
153 public void pcepUpdateMsgTest3() throws PcepParseException { 118 public void pcepUpdateMsgTest3() throws PcepParseException {
154 119
155 - // Srp, Lsp (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv), Ero
156 -
157 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x38, 120 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x38,
158 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object 121 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
159 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv 122 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
...@@ -169,39 +132,30 @@ public class PcepUpdateMsgTest { ...@@ -169,39 +132,30 @@ public class PcepUpdateMsgTest {
169 132
170 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); 133 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
171 PcepMessage message = null; 134 PcepMessage message = null;
172 - try { 135 +
173 message = reader.readFrom(buffer); 136 message = reader.readFrom(buffer);
174 - } catch (PcepParseException e) {
175 - e.printStackTrace();
176 - }
177 137
178 - if (message instanceof PcepUpdateMsg) { 138 + Assert.assertTrue("PcepMessage is not instance of PcUpd", (message instanceof PcepUpdateMsg));
179 ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); 139 ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
180 message.writeTo(buf); 140 message.writeTo(buf);
181 testupdateMsg = buf.array(); 141 testupdateMsg = buf.array();
182 142
183 - int iReadLen = buf.writerIndex() - 0; 143 + int readLen = buf.writerIndex() - 0;
184 - testupdateMsg = new byte[iReadLen]; 144 + testupdateMsg = new byte[readLen];
185 - buf.readBytes(testupdateMsg, 0, iReadLen); 145 + buf.readBytes(testupdateMsg, 0, readLen);
186 -
187 - if (Arrays.equals(updateMsg, testupdateMsg)) {
188 - Assert.assertArrayEquals(updateMsg, testupdateMsg);
189 - log.debug("updateMsg are equal :" + updateMsg);
190 - } else {
191 - Assert.fail("test case failed");
192 - log.debug("not equal");
193 - }
194 - } else {
195 - Assert.fail("test case failed");
196 - log.debug("not equal");
197 - }
198 146
147 + Assert.assertArrayEquals("PcUpd messages are not equal", updateMsg, testupdateMsg);
199 } 148 }
200 149
150 + /**
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 + */
201 @Test 156 @Test
202 public void pcepUpdateMsgTest4() throws PcepParseException { 157 public void pcepUpdateMsgTest4() throws PcepParseException {
203 158
204 - // Srp, Lsp (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv), Ero
205 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x40, 159 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x40,
206 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object 160 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
207 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv 161 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
...@@ -218,41 +172,30 @@ public class PcepUpdateMsgTest { ...@@ -218,41 +172,30 @@ public class PcepUpdateMsgTest {
218 172
219 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); 173 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
220 PcepMessage message = null; 174 PcepMessage message = null;
221 - try { 175 +
222 message = reader.readFrom(buffer); 176 message = reader.readFrom(buffer);
223 - } catch (PcepParseException e) {
224 - e.printStackTrace();
225 - }
226 177
227 - if (message instanceof PcepUpdateMsg) { 178 + Assert.assertTrue("PcepMessage is not instance of PcUpd", (message instanceof PcepUpdateMsg));
228 ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); 179 ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
229 message.writeTo(buf); 180 message.writeTo(buf);
230 testupdateMsg = buf.array(); 181 testupdateMsg = buf.array();
231 182
232 - int iReadLen = buf.writerIndex() - 0; 183 + int readLen = buf.writerIndex() - 0;
233 - testupdateMsg = new byte[iReadLen]; 184 + testupdateMsg = new byte[readLen];
234 - buf.readBytes(testupdateMsg, 0, iReadLen); 185 + buf.readBytes(testupdateMsg, 0, readLen);
235 -
236 - if (Arrays.equals(updateMsg, testupdateMsg)) {
237 - Assert.assertArrayEquals(updateMsg, testupdateMsg);
238 - log.debug("updateMsg are equal :" + updateMsg);
239 - } else {
240 - Assert.fail("test case failed");
241 - log.debug("not equal");
242 - }
243 - } else {
244 - Assert.fail("test case failed");
245 - log.debug("not equal");
246 - }
247 186
187 + Assert.assertArrayEquals("PcUpd messages are not equal", updateMsg, testupdateMsg);
248 } 188 }
249 189
190 + /**
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 + */
250 @Test 196 @Test
251 public void pcepUpdateMsgTest5() throws PcepParseException { 197 public void pcepUpdateMsgTest5() throws PcepParseException {
252 198
253 - /* Srp, Lsp (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv),
254 - * Ero
255 - */
256 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x40, 199 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x40,
257 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object 200 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
258 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv 201 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
...@@ -269,41 +212,30 @@ public class PcepUpdateMsgTest { ...@@ -269,41 +212,30 @@ public class PcepUpdateMsgTest {
269 212
270 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); 213 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
271 PcepMessage message = null; 214 PcepMessage message = null;
272 - try { 215 +
273 message = reader.readFrom(buffer); 216 message = reader.readFrom(buffer);
274 - } catch (PcepParseException e) {
275 - e.printStackTrace();
276 - }
277 217
278 - if (message instanceof PcepUpdateMsg) { 218 + Assert.assertTrue("PcepMessage is not instance of PcUpd", (message instanceof PcepUpdateMsg));
279 ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); 219 ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
280 message.writeTo(buf); 220 message.writeTo(buf);
281 testupdateMsg = buf.array(); 221 testupdateMsg = buf.array();
282 222
283 - int iReadLen = buf.writerIndex() - 0; 223 + int readLen = buf.writerIndex() - 0;
284 - testupdateMsg = new byte[iReadLen]; 224 + testupdateMsg = new byte[readLen];
285 - buf.readBytes(testupdateMsg, 0, iReadLen); 225 + buf.readBytes(testupdateMsg, 0, readLen);
286 -
287 - if (Arrays.equals(updateMsg, testupdateMsg)) {
288 - Assert.assertArrayEquals(updateMsg, testupdateMsg);
289 - log.debug("updateMsg are equal :" + updateMsg);
290 - } else {
291 - Assert.fail("test case failed");
292 - log.debug("not equal");
293 - }
294 - } else {
295 - Assert.fail("test case failed");
296 - log.debug("not equal");
297 - }
298 226
227 + Assert.assertArrayEquals("PcUpd messages are not equal", updateMsg, testupdateMsg);
299 } 228 }
300 229
230 + /**
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 + */
301 @Test 236 @Test
302 public void pcepUpdateMsgTest6() throws PcepParseException { 237 public void pcepUpdateMsgTest6() throws PcepParseException {
303 238
304 - /* Srp, Lsp (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv,
305 - * StatefulLspErrorCodeTlv), Ero
306 - */
307 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x48, 239 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x48,
308 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object 240 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
309 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv 241 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
...@@ -321,41 +253,31 @@ public class PcepUpdateMsgTest { ...@@ -321,41 +253,31 @@ public class PcepUpdateMsgTest {
321 253
322 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); 254 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
323 PcepMessage message = null; 255 PcepMessage message = null;
324 - try { 256 +
325 message = reader.readFrom(buffer); 257 message = reader.readFrom(buffer);
326 - } catch (PcepParseException e) {
327 - e.printStackTrace();
328 - }
329 258
330 - if (message instanceof PcepUpdateMsg) { 259 + Assert.assertTrue("PcepMessage is not instance of PcUpd", (message instanceof PcepUpdateMsg));
331 ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); 260 ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
332 message.writeTo(buf); 261 message.writeTo(buf);
333 testupdateMsg = buf.array(); 262 testupdateMsg = buf.array();
334 263
335 - int iReadLen = buf.writerIndex() - 0; 264 + int readLen = buf.writerIndex() - 0;
336 - testupdateMsg = new byte[iReadLen]; 265 + testupdateMsg = new byte[readLen];
337 - buf.readBytes(testupdateMsg, 0, iReadLen); 266 + buf.readBytes(testupdateMsg, 0, readLen);
338 267
339 - if (Arrays.equals(updateMsg, testupdateMsg)) { 268 + Assert.assertArrayEquals("PcUpd messages are not equal", updateMsg, testupdateMsg);
340 - Assert.assertArrayEquals(updateMsg, testupdateMsg);
341 - log.debug("updateMsg are equal :" + updateMsg);
342 - } else {
343 - Assert.fail("test case failed");
344 - log.debug("not equal");
345 - }
346 - } else {
347 - Assert.fail("test case failed");
348 - log.debug("not equal");
349 - }
350 269
351 } 270 }
352 271
272 + /**
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 + */
353 @Test 278 @Test
354 public void pcepUpdateMsgTest7() throws PcepParseException { 279 public void pcepUpdateMsgTest7() throws PcepParseException {
355 280
356 - /* Srp, Lsp (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv,
357 - * StatefulLspErrorCodeTlv), Ero
358 - */
359 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x48, 281 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x48,
360 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object 282 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
361 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv 283 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
...@@ -373,40 +295,29 @@ public class PcepUpdateMsgTest { ...@@ -373,40 +295,29 @@ public class PcepUpdateMsgTest {
373 295
374 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); 296 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
375 PcepMessage message = null; 297 PcepMessage message = null;
376 - try { 298 +
377 message = reader.readFrom(buffer); 299 message = reader.readFrom(buffer);
378 - } catch (PcepParseException e) {
379 - e.printStackTrace();
380 - }
381 300
382 - if (message instanceof PcepUpdateMsg) { 301 + Assert.assertTrue("PcepMessage is not instance of PcUpd", (message instanceof PcepUpdateMsg));
383 ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); 302 ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
384 message.writeTo(buf); 303 message.writeTo(buf);
385 testupdateMsg = buf.array(); 304 testupdateMsg = buf.array();
386 305
387 - int iReadLen = buf.writerIndex() - 0; 306 + int readLen = buf.writerIndex() - 0;
388 - testupdateMsg = new byte[iReadLen]; 307 + testupdateMsg = new byte[readLen];
389 - buf.readBytes(testupdateMsg, 0, iReadLen); 308 + buf.readBytes(testupdateMsg, 0, readLen);
390 - 309 + Assert.assertArrayEquals("PcUpd messages are not equal", updateMsg, testupdateMsg);
391 - if (Arrays.equals(updateMsg, testupdateMsg)) {
392 - Assert.assertArrayEquals(updateMsg, testupdateMsg);
393 - log.debug("updateMsg are equal :" + updateMsg);
394 - } else {
395 - Assert.fail("test case failed");
396 - log.debug("not equal");
397 - }
398 - } else {
399 - Assert.fail("test case failed");
400 - log.debug("not equal");
401 - }
402 } 310 }
403 311
312 + /**
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 + */
404 @Test 318 @Test
405 public void pcepUpdateMsgTest8() throws PcepParseException { 319 public void pcepUpdateMsgTest8() throws PcepParseException {
406 320
407 - /* Srp, Lsp (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv,
408 - * StatefulLspErrorCodeTlv), Ero (IPv4SubObject)
409 - */
410 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x50, 321 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x50,
411 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object 322 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
412 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv 323 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
...@@ -425,40 +336,30 @@ public class PcepUpdateMsgTest { ...@@ -425,40 +336,30 @@ public class PcepUpdateMsgTest {
425 336
426 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); 337 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
427 PcepMessage message = null; 338 PcepMessage message = null;
428 - try { 339 +
429 message = reader.readFrom(buffer); 340 message = reader.readFrom(buffer);
430 - } catch (PcepParseException e) {
431 - e.printStackTrace();
432 - }
433 341
434 - if (message instanceof PcepUpdateMsg) { 342 + Assert.assertTrue("PcepMessage is not instance of PcUpd", (message instanceof PcepUpdateMsg));
435 ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); 343 ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
436 message.writeTo(buf); 344 message.writeTo(buf);
437 testupdateMsg = buf.array(); 345 testupdateMsg = buf.array();
438 346
439 - int iReadLen = buf.writerIndex() - 0; 347 + int readLen = buf.writerIndex() - 0;
440 - testupdateMsg = new byte[iReadLen]; 348 + testupdateMsg = new byte[readLen];
441 - buf.readBytes(testupdateMsg, 0, iReadLen); 349 + buf.readBytes(testupdateMsg, 0, readLen);
442 350
443 - if (Arrays.equals(updateMsg, testupdateMsg)) { 351 + Assert.assertArrayEquals("PcUpd messages are not equal", updateMsg, testupdateMsg);
444 - Assert.assertArrayEquals(updateMsg, testupdateMsg);
445 - log.debug("updateMsg are equal :" + updateMsg);
446 - } else {
447 - Assert.fail("test case failed");
448 - log.debug("not equal");
449 - }
450 - } else {
451 - Assert.fail("test case failed");
452 - log.debug("not equal");
453 - }
454 } 352 }
455 353
354 + /**
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 + */
456 @Test 360 @Test
457 public void pcepUpdateMsgTest9() throws PcepParseException { 361 public void pcepUpdateMsgTest9() throws PcepParseException {
458 362
459 - /* Srp, Lsp (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv,
460 - * StatefulLspErrorCodeTlv), Ero (IPv4SubObject, IPv4SubObject)
461 - */
462 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x58, 363 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x58,
463 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object 364 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
464 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv 365 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
...@@ -478,40 +379,30 @@ public class PcepUpdateMsgTest { ...@@ -478,40 +379,30 @@ public class PcepUpdateMsgTest {
478 379
479 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); 380 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
480 PcepMessage message = null; 381 PcepMessage message = null;
481 - try { 382 +
482 message = reader.readFrom(buffer); 383 message = reader.readFrom(buffer);
483 - } catch (PcepParseException e) {
484 - e.printStackTrace();
485 - }
486 384
487 - if (message instanceof PcepUpdateMsg) { 385 + Assert.assertTrue("PcepMessage is not instance of PcUpd", (message instanceof PcepUpdateMsg));
488 ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); 386 ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
489 message.writeTo(buf); 387 message.writeTo(buf);
490 testupdateMsg = buf.array(); 388 testupdateMsg = buf.array();
491 389
492 - int iReadLen = buf.writerIndex() - 0; 390 + int readLen = buf.writerIndex() - 0;
493 - testupdateMsg = new byte[iReadLen]; 391 + testupdateMsg = new byte[readLen];
494 - buf.readBytes(testupdateMsg, 0, iReadLen); 392 + buf.readBytes(testupdateMsg, 0, readLen);
495 393
496 - if (Arrays.equals(updateMsg, testupdateMsg)) { 394 + Assert.assertArrayEquals("PcUpd messages are not equal", updateMsg, testupdateMsg);
497 - Assert.assertArrayEquals(updateMsg, testupdateMsg);
498 - log.debug("updateMsg are equal :" + updateMsg);
499 - } else {
500 - Assert.fail("test case failed");
501 - log.debug("not equal");
502 - }
503 - } else {
504 - Assert.fail("test case failed");
505 - log.debug("not equal");
506 - }
507 } 395 }
508 396
397 + /**
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 + */
509 @Test 403 @Test
510 public void pcepUpdateMsgTest10() throws PcepParseException { 404 public void pcepUpdateMsgTest10() throws PcepParseException {
511 405
512 - /* Srp, Lsp (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv,
513 - * StatefulLspErrorCodeTlv), Ero (IPv4SubObject, IPv4SubObject), Lspa
514 - */
515 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x6c, 406 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x6c,
516 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object 407 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
517 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv 408 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
...@@ -533,40 +424,30 @@ public class PcepUpdateMsgTest { ...@@ -533,40 +424,30 @@ public class PcepUpdateMsgTest {
533 424
534 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); 425 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
535 PcepMessage message = null; 426 PcepMessage message = null;
536 - try { 427 +
537 message = reader.readFrom(buffer); 428 message = reader.readFrom(buffer);
538 - } catch (PcepParseException e) {
539 - e.printStackTrace();
540 - }
541 429
542 - if (message instanceof PcepUpdateMsg) { 430 + Assert.assertTrue("PcepMessage is not instance of PcUpd", (message instanceof PcepUpdateMsg));
543 ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); 431 ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
544 message.writeTo(buf); 432 message.writeTo(buf);
545 testupdateMsg = buf.array(); 433 testupdateMsg = buf.array();
546 434
547 - int iReadLen = buf.writerIndex() - 0; 435 + int readLen = buf.writerIndex() - 0;
548 - testupdateMsg = new byte[iReadLen]; 436 + testupdateMsg = new byte[readLen];
549 - buf.readBytes(testupdateMsg, 0, iReadLen); 437 + buf.readBytes(testupdateMsg, 0, readLen);
550 438
551 - if (Arrays.equals(updateMsg, testupdateMsg)) { 439 + Assert.assertArrayEquals("PcUpd messages are not equal", updateMsg, testupdateMsg);
552 - Assert.assertArrayEquals(updateMsg, testupdateMsg);
553 - log.debug("updateMsg are equal :" + updateMsg);
554 - } else {
555 - Assert.fail("test case failed");
556 - log.debug("not equal");
557 - }
558 - } else {
559 - Assert.fail("test case failed");
560 - log.debug("not equal");
561 - }
562 } 440 }
563 441
442 + /**
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 + */
564 @Test 448 @Test
565 public void pcepUpdateMsgTest11() throws PcepParseException { 449 public void pcepUpdateMsgTest11() throws PcepParseException {
566 450
567 - /* Srp, Lsp (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv,
568 - * StatefulLspErrorCodeTlv), Ero (IPv4SubObject, IPv4SubObject),Lspa, Metric Object
569 - */
570 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x78, 451 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x78,
571 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object 452 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
572 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv 453 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
...@@ -589,40 +470,30 @@ public class PcepUpdateMsgTest { ...@@ -589,40 +470,30 @@ public class PcepUpdateMsgTest {
589 470
590 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); 471 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
591 PcepMessage message = null; 472 PcepMessage message = null;
592 - try { 473 +
593 message = reader.readFrom(buffer); 474 message = reader.readFrom(buffer);
594 - } catch (PcepParseException e) {
595 - e.printStackTrace();
596 - }
597 475
598 - if (message instanceof PcepUpdateMsg) { 476 + Assert.assertTrue("PcepMessage is not instance of PcUpd", (message instanceof PcepUpdateMsg));
599 ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); 477 ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
600 message.writeTo(buf); 478 message.writeTo(buf);
601 testupdateMsg = buf.array(); 479 testupdateMsg = buf.array();
602 480
603 - int iReadLen = buf.writerIndex() - 0; 481 + int readLen = buf.writerIndex() - 0;
604 - testupdateMsg = new byte[iReadLen]; 482 + testupdateMsg = new byte[readLen];
605 - buf.readBytes(testupdateMsg, 0, iReadLen); 483 + buf.readBytes(testupdateMsg, 0, readLen);
606 484
607 - if (Arrays.equals(updateMsg, testupdateMsg)) { 485 + Assert.assertArrayEquals("PcUpd messages are not equal", updateMsg, testupdateMsg);
608 - Assert.assertArrayEquals(updateMsg, testupdateMsg);
609 - log.debug("updateMsg are equal :" + updateMsg);
610 - } else {
611 - Assert.fail("test case failed");
612 - log.debug("not equal");
613 - }
614 - } else {
615 - Assert.fail("test case failed");
616 - log.debug("not equal");
617 - }
618 } 486 }
619 487
488 + /**
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 + */
620 @Test 494 @Test
621 public void pcepUpdateMsgTest12() throws PcepParseException { 495 public void pcepUpdateMsgTest12() throws PcepParseException {
622 496
623 - /* Srp, Lsp (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv,
624 - * StatefulLspErrorCodeTlv), Ero (IPv4SubObject, IPv4SubObject),Lspa, metric Object
625 - */
626 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x70, 497 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x70,
627 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object 498 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
628 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object 499 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object
...@@ -644,40 +515,30 @@ public class PcepUpdateMsgTest { ...@@ -644,40 +515,30 @@ public class PcepUpdateMsgTest {
644 515
645 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); 516 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
646 PcepMessage message = null; 517 PcepMessage message = null;
647 - try { 518 +
648 message = reader.readFrom(buffer); 519 message = reader.readFrom(buffer);
649 - } catch (PcepParseException e) {
650 - e.printStackTrace();
651 - }
652 520
653 - if (message instanceof PcepUpdateMsg) { 521 + Assert.assertTrue("PcepMessage is not instance of PcUpd", (message instanceof PcepUpdateMsg));
654 ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); 522 ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
655 message.writeTo(buf); 523 message.writeTo(buf);
656 testupdateMsg = buf.array(); 524 testupdateMsg = buf.array();
657 525
658 - int iReadLen = buf.writerIndex() - 0; 526 + int readLen = buf.writerIndex() - 0;
659 - testupdateMsg = new byte[iReadLen]; 527 + testupdateMsg = new byte[readLen];
660 - buf.readBytes(testupdateMsg, 0, iReadLen); 528 + buf.readBytes(testupdateMsg, 0, readLen);
661 529
662 - if (Arrays.equals(updateMsg, testupdateMsg)) { 530 + Assert.assertArrayEquals("PcUpd messages are not equal", updateMsg, testupdateMsg);
663 - Assert.assertArrayEquals(updateMsg, testupdateMsg);
664 - log.debug("updateMsg are equal :" + updateMsg);
665 - } else {
666 - Assert.fail("test case failed");
667 - log.debug("not equal");
668 - }
669 - } else {
670 - Assert.fail("test case failed");
671 - log.debug("not equal");
672 - }
673 } 531 }
674 532
533 + /**
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 + */
675 @Test 539 @Test
676 public void pcepUpdateMsgTest13() throws PcepParseException { 540 public void pcepUpdateMsgTest13() throws PcepParseException {
677 541
678 - /* Srp, Lsp (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv,
679 - * StatefulLspErrorCodeTlv), Ero (IPv4SubObject, IPv4SubObject),Lspa, metric Object
680 - */
681 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x70, 542 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x70,
682 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object 543 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
683 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object 544 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object
...@@ -699,40 +560,30 @@ public class PcepUpdateMsgTest { ...@@ -699,40 +560,30 @@ public class PcepUpdateMsgTest {
699 560
700 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); 561 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
701 PcepMessage message = null; 562 PcepMessage message = null;
702 - try { 563 +
703 message = reader.readFrom(buffer); 564 message = reader.readFrom(buffer);
704 - } catch (PcepParseException e) {
705 - e.printStackTrace();
706 - }
707 565
708 - if (message instanceof PcepUpdateMsg) { 566 + Assert.assertTrue("PcepMessage is not instance of PcUpd", (message instanceof PcepUpdateMsg));
709 ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); 567 ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
710 message.writeTo(buf); 568 message.writeTo(buf);
711 testupdateMsg = buf.array(); 569 testupdateMsg = buf.array();
712 570
713 - int iReadLen = buf.writerIndex() - 0; 571 + int readLen = buf.writerIndex() - 0;
714 - testupdateMsg = new byte[iReadLen]; 572 + testupdateMsg = new byte[readLen];
715 - buf.readBytes(testupdateMsg, 0, iReadLen); 573 + buf.readBytes(testupdateMsg, 0, readLen);
716 574
717 - if (Arrays.equals(updateMsg, testupdateMsg)) { 575 + Assert.assertArrayEquals("PcUpd messages are not equal", updateMsg, testupdateMsg);
718 - Assert.assertArrayEquals(updateMsg, testupdateMsg);
719 - log.debug("updateMsg are equal :" + updateMsg);
720 - } else {
721 - Assert.fail("test case failed");
722 - log.debug("not equal");
723 - }
724 - } else {
725 - Assert.fail("test case failed");
726 - log.debug("not equal");
727 - }
728 } 576 }
729 577
578 + /**
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 + */
730 @Test 584 @Test
731 public void pcepUpdateMsgTest14() throws PcepParseException { 585 public void pcepUpdateMsgTest14() throws PcepParseException {
732 586
733 - /* Srp, Lsp (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv),
734 - * Ero (IPv4SubObject, IPv4SubObject),Lspa, metric Object
735 - */
736 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x68, 587 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x68,
737 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object 588 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
738 0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x10, 0x03, //LSP object 589 0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x10, 0x03, //LSP object
...@@ -753,40 +604,30 @@ public class PcepUpdateMsgTest { ...@@ -753,40 +604,30 @@ public class PcepUpdateMsgTest {
753 604
754 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); 605 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
755 PcepMessage message = null; 606 PcepMessage message = null;
756 - try { 607 +
757 message = reader.readFrom(buffer); 608 message = reader.readFrom(buffer);
758 - } catch (PcepParseException e) {
759 - e.printStackTrace();
760 - }
761 609
762 - if (message instanceof PcepUpdateMsg) { 610 + Assert.assertTrue("PcepMessage is not instance of PcUpd", (message instanceof PcepUpdateMsg));
763 ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); 611 ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
764 message.writeTo(buf); 612 message.writeTo(buf);
765 testupdateMsg = buf.array(); 613 testupdateMsg = buf.array();
766 614
767 - int iReadLen = buf.writerIndex() - 0; 615 + int readLen = buf.writerIndex() - 0;
768 - testupdateMsg = new byte[iReadLen]; 616 + testupdateMsg = new byte[readLen];
769 - buf.readBytes(testupdateMsg, 0, iReadLen); 617 + buf.readBytes(testupdateMsg, 0, readLen);
770 618
771 - if (Arrays.equals(updateMsg, testupdateMsg)) { 619 + Assert.assertArrayEquals("PcUpd messages are not equal", updateMsg, testupdateMsg);
772 - Assert.assertArrayEquals(updateMsg, testupdateMsg);
773 - log.debug("updateMsg are equal :" + updateMsg);
774 - } else {
775 - Assert.fail("test case failed");
776 - log.debug("not equal");
777 - }
778 - } else {
779 - Assert.fail("test case failed");
780 - log.debug("not equal");
781 - }
782 } 620 }
783 621
622 + /**
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 + */
784 @Test 628 @Test
785 public void pcepUpdateMsgTest15() throws PcepParseException { 629 public void pcepUpdateMsgTest15() throws PcepParseException {
786 630
787 - /* Srp, Lsp (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv),
788 - * Ero (IPv4SubObject, IPv4SubObject),Lspa, metric Object
789 - */
790 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x68, 631 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x68,
791 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object 632 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
792 0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x10, 0x03, //LSP object 633 0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x10, 0x03, //LSP object
...@@ -807,40 +648,30 @@ public class PcepUpdateMsgTest { ...@@ -807,40 +648,30 @@ public class PcepUpdateMsgTest {
807 648
808 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); 649 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
809 PcepMessage message = null; 650 PcepMessage message = null;
810 - try { 651 +
811 message = reader.readFrom(buffer); 652 message = reader.readFrom(buffer);
812 - } catch (PcepParseException e) {
813 - e.printStackTrace();
814 - }
815 653
816 - if (message instanceof PcepUpdateMsg) { 654 + Assert.assertTrue("PcepMessage is not instance of PcUpd", (message instanceof PcepUpdateMsg));
817 ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); 655 ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
818 message.writeTo(buf); 656 message.writeTo(buf);
819 testupdateMsg = buf.array(); 657 testupdateMsg = buf.array();
820 658
821 - int iReadLen = buf.writerIndex() - 0; 659 + int readLen = buf.writerIndex() - 0;
822 - testupdateMsg = new byte[iReadLen]; 660 + testupdateMsg = new byte[readLen];
823 - buf.readBytes(testupdateMsg, 0, iReadLen); 661 + buf.readBytes(testupdateMsg, 0, readLen);
824 662
825 - if (Arrays.equals(updateMsg, testupdateMsg)) { 663 + Assert.assertArrayEquals("PcUpd messages are not equal", updateMsg, testupdateMsg);
826 - Assert.assertArrayEquals(updateMsg, testupdateMsg);
827 - log.debug("updateMsg are equal :" + updateMsg);
828 - } else {
829 - Assert.fail("test case failed");
830 - log.debug("not equal");
831 - }
832 - } else {
833 - Assert.fail("test case failed");
834 - log.debug("not equal");
835 - }
836 } 664 }
837 665
666 + /**
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 + */
838 @Test 672 @Test
839 public void pcepUpdateMsgTest16() throws PcepParseException { 673 public void pcepUpdateMsgTest16() throws PcepParseException {
840 674
841 - /* Srp, Lsp (StatefulIPv4LspIdentidiersTlv),
842 - * Ero (IPv4SubObject, IPv4SubObject),Lspa, metric Object
843 - */
844 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x60, 675 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x60,
845 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object 676 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
846 0x20, 0x10, 0x00, 0x1C, 0x00, 0x00, 0x10, 0x03, //LSP object 677 0x20, 0x10, 0x00, 0x1C, 0x00, 0x00, 0x10, 0x03, //LSP object
...@@ -860,40 +691,30 @@ public class PcepUpdateMsgTest { ...@@ -860,40 +691,30 @@ public class PcepUpdateMsgTest {
860 691
861 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); 692 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
862 PcepMessage message = null; 693 PcepMessage message = null;
863 - try { 694 +
864 message = reader.readFrom(buffer); 695 message = reader.readFrom(buffer);
865 - } catch (PcepParseException e) {
866 - e.printStackTrace();
867 - }
868 696
869 - if (message instanceof PcepUpdateMsg) { 697 + Assert.assertTrue("PcepMessage is not instance of PcUpd", (message instanceof PcepUpdateMsg));
870 ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); 698 ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
871 message.writeTo(buf); 699 message.writeTo(buf);
872 testupdateMsg = buf.array(); 700 testupdateMsg = buf.array();
873 701
874 - int iReadLen = buf.writerIndex() - 0; 702 + int readLen = buf.writerIndex() - 0;
875 - testupdateMsg = new byte[iReadLen]; 703 + testupdateMsg = new byte[readLen];
876 - buf.readBytes(testupdateMsg, 0, iReadLen); 704 + buf.readBytes(testupdateMsg, 0, readLen);
877 705
878 - if (Arrays.equals(updateMsg, testupdateMsg)) { 706 + Assert.assertArrayEquals("PcUpd messages are not equal", updateMsg, testupdateMsg);
879 - Assert.assertArrayEquals(updateMsg, testupdateMsg);
880 - log.debug("updateMsg are equal :" + updateMsg);
881 - } else {
882 - Assert.fail("test case failed");
883 - log.debug("not equal");
884 - }
885 - } else {
886 - Assert.fail("test case failed");
887 - log.debug("not equal");
888 - }
889 } 707 }
890 708
709 + /**
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 + */
891 @Test 715 @Test
892 public void pcepUpdateMsgTest17() throws PcepParseException { 716 public void pcepUpdateMsgTest17() throws PcepParseException {
893 717
894 - /* Srp, Lsp (StatefulIPv4LspIdentidiersTlv),
895 - * Ero (IPv4SubObject, IPv4SubObject),Lspa
896 - */
897 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x54, 718 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x54,
898 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object 719 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
899 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x05, //LSP object 720 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x05, //LSP object
...@@ -912,40 +733,30 @@ public class PcepUpdateMsgTest { ...@@ -912,40 +733,30 @@ public class PcepUpdateMsgTest {
912 733
913 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); 734 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
914 PcepMessage message = null; 735 PcepMessage message = null;
915 - try { 736 +
916 message = reader.readFrom(buffer); 737 message = reader.readFrom(buffer);
917 - } catch (PcepParseException e) {
918 - e.printStackTrace();
919 - }
920 738
921 - if (message instanceof PcepUpdateMsg) { 739 + Assert.assertTrue("PcepMessage is not instance of PcUpd", (message instanceof PcepUpdateMsg));
922 ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); 740 ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
923 message.writeTo(buf); 741 message.writeTo(buf);
924 testupdateMsg = buf.array(); 742 testupdateMsg = buf.array();
925 743
926 - int iReadLen = buf.writerIndex() - 0; 744 + int readLen = buf.writerIndex() - 0;
927 - testupdateMsg = new byte[iReadLen]; 745 + testupdateMsg = new byte[readLen];
928 - buf.readBytes(testupdateMsg, 0, iReadLen); 746 + buf.readBytes(testupdateMsg, 0, readLen);
929 747
930 - if (Arrays.equals(updateMsg, testupdateMsg)) { 748 + Assert.assertArrayEquals("PcUpd messages are not equal", updateMsg, testupdateMsg);
931 - Assert.assertArrayEquals(updateMsg, testupdateMsg);
932 - log.debug("updateMsg are equal :" + updateMsg);
933 - } else {
934 - Assert.fail("test case failed");
935 - log.debug("not equal");
936 - }
937 - } else {
938 - Assert.fail("test case failed");
939 - log.debug("not equal");
940 - }
941 } 749 }
942 750
751 + /**
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 + */
943 @Test 757 @Test
944 public void pcepUpdateMsgTest18() throws PcepParseException { 758 public void pcepUpdateMsgTest18() throws PcepParseException {
945 759
946 - /* Srp, Lsp (StatefulIPv4LspIdentidiersTlv),
947 - * Ero (IPv4SubObject, IPv4SubObject),Metric Object
948 - */
949 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x4c, 760 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x4c,
950 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object 761 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
951 0x20, 0x10, 0x00, 0x1C, 0x00, 0x00, 0x10, 0x03, //LSP object 762 0x20, 0x10, 0x00, 0x1C, 0x00, 0x00, 0x10, 0x03, //LSP object
...@@ -963,40 +774,30 @@ public class PcepUpdateMsgTest { ...@@ -963,40 +774,30 @@ public class PcepUpdateMsgTest {
963 774
964 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); 775 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
965 PcepMessage message = null; 776 PcepMessage message = null;
966 - try { 777 +
967 message = reader.readFrom(buffer); 778 message = reader.readFrom(buffer);
968 - } catch (PcepParseException e) {
969 - e.printStackTrace();
970 - }
971 779
972 - if (message instanceof PcepUpdateMsg) { 780 + Assert.assertTrue("PcepMessage is not instance of PcUpd", (message instanceof PcepUpdateMsg));
973 ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); 781 ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
974 message.writeTo(buf); 782 message.writeTo(buf);
975 testupdateMsg = buf.array(); 783 testupdateMsg = buf.array();
976 784
977 - int iReadLen = buf.writerIndex() - 0; 785 + int readLen = buf.writerIndex() - 0;
978 - testupdateMsg = new byte[iReadLen]; 786 + testupdateMsg = new byte[readLen];
979 - buf.readBytes(testupdateMsg, 0, iReadLen); 787 + buf.readBytes(testupdateMsg, 0, readLen);
980 788
981 - if (Arrays.equals(updateMsg, testupdateMsg)) { 789 + Assert.assertArrayEquals("PcUpd messages are not equal", updateMsg, testupdateMsg);
982 - Assert.assertArrayEquals(updateMsg, testupdateMsg);
983 - log.debug("updateMsg are equal :" + updateMsg);
984 - } else {
985 - Assert.fail("test case failed");
986 - log.debug("not equal");
987 - }
988 - } else {
989 - Assert.fail("test case failed");
990 - log.debug("not equal");
991 - }
992 } 790 }
993 791
792 + /**
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 + */
994 @Test 798 @Test
995 public void pcepUpdateMsgTest19() throws PcepParseException { 799 public void pcepUpdateMsgTest19() throws PcepParseException {
996 800
997 - /* Srp, Lsp (StatefulIPv4LspIdentidiersTlv),
998 - * Ero (IPv4SubObject, IPv4SubObject),Metric-list
999 - */
1000 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x58, 801 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x58,
1001 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object 802 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
1002 0x20, 0x10, 0x00, 0x1C, 0x00, 0x00, 0x10, 0x03, //LSP object 803 0x20, 0x10, 0x00, 0x1C, 0x00, 0x00, 0x10, 0x03, //LSP object
...@@ -1015,40 +816,30 @@ public class PcepUpdateMsgTest { ...@@ -1015,40 +816,30 @@ public class PcepUpdateMsgTest {
1015 816
1016 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); 817 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
1017 PcepMessage message = null; 818 PcepMessage message = null;
1018 - try { 819 +
1019 message = reader.readFrom(buffer); 820 message = reader.readFrom(buffer);
1020 - } catch (PcepParseException e) {
1021 - e.printStackTrace();
1022 - }
1023 821
1024 - if (message instanceof PcepUpdateMsg) { 822 + Assert.assertTrue("PcepMessage is not instance of PcUpd", (message instanceof PcepUpdateMsg));
1025 ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); 823 ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
1026 message.writeTo(buf); 824 message.writeTo(buf);
1027 testupdateMsg = buf.array(); 825 testupdateMsg = buf.array();
1028 826
1029 - int iReadLen = buf.writerIndex() - 0; 827 + int readLen = buf.writerIndex() - 0;
1030 - testupdateMsg = new byte[iReadLen]; 828 + testupdateMsg = new byte[readLen];
1031 - buf.readBytes(testupdateMsg, 0, iReadLen); 829 + buf.readBytes(testupdateMsg, 0, readLen);
1032 830
1033 - if (Arrays.equals(updateMsg, testupdateMsg)) { 831 + Assert.assertArrayEquals("PcUpd messages are not equal", updateMsg, testupdateMsg);
1034 - Assert.assertArrayEquals(updateMsg, testupdateMsg);
1035 - log.debug("updateMsg are equal :" + updateMsg);
1036 - } else {
1037 - Assert.fail("test case failed");
1038 - log.debug("not equal");
1039 - }
1040 - } else {
1041 - Assert.fail("test case failed");
1042 - log.debug("not equal");
1043 - }
1044 } 832 }
1045 833
834 + /**
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 + */
1046 @Test 840 @Test
1047 public void pcepUpdateMsgTest20() throws PcepParseException { 841 public void pcepUpdateMsgTest20() throws PcepParseException {
1048 842
1049 - /* Srp, Lsp (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv,
1050 - * StatefulLspErrorCodeTlv),Ero (IPv4SubObject, IPv4SubObject),Lspa, Bandwidth, Metric Object
1051 - */
1052 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x80, 843 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x80,
1053 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object 844 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
1054 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv 845 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
...@@ -1072,40 +863,30 @@ public class PcepUpdateMsgTest { ...@@ -1072,40 +863,30 @@ public class PcepUpdateMsgTest {
1072 863
1073 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); 864 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
1074 PcepMessage message = null; 865 PcepMessage message = null;
1075 - try { 866 +
1076 message = reader.readFrom(buffer); 867 message = reader.readFrom(buffer);
1077 - } catch (PcepParseException e) {
1078 - e.printStackTrace();
1079 - }
1080 868
1081 - if (message instanceof PcepUpdateMsg) { 869 + Assert.assertTrue("PcepMessage is not instance of PcUpd", (message instanceof PcepUpdateMsg));
1082 ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); 870 ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
1083 message.writeTo(buf); 871 message.writeTo(buf);
1084 testupdateMsg = buf.array(); 872 testupdateMsg = buf.array();
1085 873
1086 - int iReadLen = buf.writerIndex() - 0; 874 + int readLen = buf.writerIndex() - 0;
1087 - testupdateMsg = new byte[iReadLen]; 875 + testupdateMsg = new byte[readLen];
1088 - buf.readBytes(testupdateMsg, 0, iReadLen); 876 + buf.readBytes(testupdateMsg, 0, readLen);
1089 877
1090 - if (Arrays.equals(updateMsg, testupdateMsg)) { 878 + Assert.assertArrayEquals("PcUpd messages are not equal", updateMsg, testupdateMsg);
1091 - Assert.assertArrayEquals(updateMsg, testupdateMsg);
1092 - log.debug("updateMsg are equal :" + updateMsg);
1093 - } else {
1094 - Assert.fail("test case failed");
1095 - log.debug("not equal");
1096 - }
1097 - } else {
1098 - Assert.fail("test case failed");
1099 - log.debug("not equal");
1100 - }
1101 } 879 }
1102 880
881 + /**
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 + */
1103 @Test 887 @Test
1104 public void pcepUpdateMsgTest21() throws PcepParseException { 888 public void pcepUpdateMsgTest21() throws PcepParseException {
1105 889
1106 - /* Srp, Lsp (StatefulIPv4LspIdentidiersTlv),
1107 - * Ero (IPv4SubObject, IPv4SubObject), Bandwidth
1108 - */
1109 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x48, 890 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x48,
1110 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object 891 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
1111 0x20, 0x10, 0x00, 0x1C, 0x00, 0x00, 0x10, 0x03, //LSP object 892 0x20, 0x10, 0x00, 0x1C, 0x00, 0x00, 0x10, 0x03, //LSP object
...@@ -1123,40 +904,30 @@ public class PcepUpdateMsgTest { ...@@ -1123,40 +904,30 @@ public class PcepUpdateMsgTest {
1123 904
1124 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); 905 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
1125 PcepMessage message = null; 906 PcepMessage message = null;
1126 - try { 907 +
1127 message = reader.readFrom(buffer); 908 message = reader.readFrom(buffer);
1128 - } catch (PcepParseException e) {
1129 - e.printStackTrace();
1130 - }
1131 909
1132 - if (message instanceof PcepUpdateMsg) { 910 + Assert.assertTrue("PcepMessage is not instance of PcUpd", (message instanceof PcepUpdateMsg));
1133 ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); 911 ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
1134 message.writeTo(buf); 912 message.writeTo(buf);
1135 testupdateMsg = buf.array(); 913 testupdateMsg = buf.array();
1136 914
1137 - int iReadLen = buf.writerIndex() - 0; 915 + int readLen = buf.writerIndex() - 0;
1138 - testupdateMsg = new byte[iReadLen]; 916 + testupdateMsg = new byte[readLen];
1139 - buf.readBytes(testupdateMsg, 0, iReadLen); 917 + buf.readBytes(testupdateMsg, 0, readLen);
1140 918
1141 - if (Arrays.equals(updateMsg, testupdateMsg)) { 919 + Assert.assertArrayEquals("PcUpd messages are not equal", updateMsg, testupdateMsg);
1142 - Assert.assertArrayEquals(updateMsg, testupdateMsg);
1143 - log.debug("updateMsg are equal :" + updateMsg);
1144 - } else {
1145 - Assert.fail("test case failed");
1146 - log.debug("not equal");
1147 - }
1148 - } else {
1149 - Assert.fail("test case failed");
1150 - log.debug("not equal");
1151 - }
1152 } 920 }
1153 921
922 + /**
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 + */
1154 @Test 928 @Test
1155 public void pcepUpdateMsgTest22() throws PcepParseException { 929 public void pcepUpdateMsgTest22() throws PcepParseException {
1156 930
1157 - /* Srp, Lsp (StatefulIPv4LspIdentidiersTlv),
1158 - * Ero (IPv4SubObject, IPv4SubObject), Lspa, Bandwidth
1159 - */
1160 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x5C, 931 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x5C,
1161 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object 932 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
1162 0x20, 0x10, 0x00, 0x1C, 0x00, 0x00, 0x10, 0x03, //LSP object 933 0x20, 0x10, 0x00, 0x1C, 0x00, 0x00, 0x10, 0x03, //LSP object
...@@ -1176,40 +947,30 @@ public class PcepUpdateMsgTest { ...@@ -1176,40 +947,30 @@ public class PcepUpdateMsgTest {
1176 947
1177 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); 948 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
1178 PcepMessage message = null; 949 PcepMessage message = null;
1179 - try { 950 +
1180 message = reader.readFrom(buffer); 951 message = reader.readFrom(buffer);
1181 - } catch (PcepParseException e) {
1182 - e.printStackTrace();
1183 - }
1184 952
1185 - if (message instanceof PcepUpdateMsg) { 953 + Assert.assertTrue("PcepMessage is not instance of PcUpd", (message instanceof PcepUpdateMsg));
1186 ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); 954 ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
1187 message.writeTo(buf); 955 message.writeTo(buf);
1188 testupdateMsg = buf.array(); 956 testupdateMsg = buf.array();
1189 957
1190 - int iReadLen = buf.writerIndex() - 0; 958 + int readLen = buf.writerIndex() - 0;
1191 - testupdateMsg = new byte[iReadLen]; 959 + testupdateMsg = new byte[readLen];
1192 - buf.readBytes(testupdateMsg, 0, iReadLen); 960 + buf.readBytes(testupdateMsg, 0, readLen);
1193 961
1194 - if (Arrays.equals(updateMsg, testupdateMsg)) { 962 + Assert.assertArrayEquals("PcUpd messages are not equal", updateMsg, testupdateMsg);
1195 - Assert.assertArrayEquals(updateMsg, testupdateMsg);
1196 - log.debug("updateMsg are equal :" + updateMsg);
1197 - } else {
1198 - Assert.fail("test case failed");
1199 - log.debug("not equal");
1200 - }
1201 - } else {
1202 - Assert.fail("test case failed");
1203 - log.debug("not equal");
1204 - }
1205 } 963 }
1206 964
965 + /**
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 + */
1207 @Test 971 @Test
1208 public void pcepUpdateMsgTest23() throws PcepParseException { 972 public void pcepUpdateMsgTest23() throws PcepParseException {
1209 973
1210 - /* Srp, Lsp (StatefulIPv4LspIdentidiersTlv),
1211 - * Ero (IPv4SubObject, IPv4SubObject), Lspa, Bandwidth, Metric Object
1212 - */
1213 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x68, 974 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x68,
1214 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object 975 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
1215 0x20, 0x10, 0x00, 0x1C, 0x00, 0x00, 0x10, 0x03, //LSP object 976 0x20, 0x10, 0x00, 0x1C, 0x00, 0x00, 0x10, 0x03, //LSP object
...@@ -1230,40 +991,30 @@ public class PcepUpdateMsgTest { ...@@ -1230,40 +991,30 @@ public class PcepUpdateMsgTest {
1230 991
1231 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); 992 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
1232 PcepMessage message = null; 993 PcepMessage message = null;
1233 - try { 994 +
1234 message = reader.readFrom(buffer); 995 message = reader.readFrom(buffer);
1235 - } catch (PcepParseException e) {
1236 - e.printStackTrace();
1237 - }
1238 996
1239 - if (message instanceof PcepUpdateMsg) { 997 + Assert.assertTrue("PcepMessage is not instance of PcUpd", (message instanceof PcepUpdateMsg));
1240 ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); 998 ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
1241 message.writeTo(buf); 999 message.writeTo(buf);
1242 testupdateMsg = buf.array(); 1000 testupdateMsg = buf.array();
1243 1001
1244 - int iReadLen = buf.writerIndex() - 0; 1002 + int readLen = buf.writerIndex() - 0;
1245 - testupdateMsg = new byte[iReadLen]; 1003 + testupdateMsg = new byte[readLen];
1246 - buf.readBytes(testupdateMsg, 0, iReadLen); 1004 + buf.readBytes(testupdateMsg, 0, readLen);
1247 1005
1248 - if (Arrays.equals(updateMsg, testupdateMsg)) { 1006 + Assert.assertArrayEquals("PcUpd messages are not equal", updateMsg, testupdateMsg);
1249 - Assert.assertArrayEquals(updateMsg, testupdateMsg);
1250 - log.debug("updateMsg are equal :" + updateMsg);
1251 - } else {
1252 - Assert.fail("test case failed");
1253 - log.debug("not equal");
1254 - }
1255 - } else {
1256 - Assert.fail("test case failed");
1257 - log.debug("not equal");
1258 - }
1259 } 1007 }
1260 1008
1009 + /**
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 + */
1261 @Test 1015 @Test
1262 public void pcepUpdateMsgTest24() throws PcepParseException { 1016 public void pcepUpdateMsgTest24() throws PcepParseException {
1263 1017
1264 - /* Srp, Lsp (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv)
1265 - * Ero (IPv4SubObject, IPv4SubObject), Lspa, Bandwidth, Metric Object
1266 - */
1267 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x70, 1018 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x70,
1268 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object 1019 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
1269 0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x10, 0x03, //LSP object 1020 0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x10, 0x03, //LSP object
...@@ -1285,40 +1036,30 @@ public class PcepUpdateMsgTest { ...@@ -1285,40 +1036,30 @@ public class PcepUpdateMsgTest {
1285 1036
1286 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); 1037 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
1287 PcepMessage message = null; 1038 PcepMessage message = null;
1288 - try { 1039 +
1289 message = reader.readFrom(buffer); 1040 message = reader.readFrom(buffer);
1290 - } catch (PcepParseException e) {
1291 - e.printStackTrace();
1292 - }
1293 1041
1294 - if (message instanceof PcepUpdateMsg) { 1042 + Assert.assertTrue("PcepMessage is not instance of PcUpd", (message instanceof PcepUpdateMsg));
1295 ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); 1043 ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
1296 message.writeTo(buf); 1044 message.writeTo(buf);
1297 testupdateMsg = buf.array(); 1045 testupdateMsg = buf.array();
1298 1046
1299 - int iReadLen = buf.writerIndex() - 0; 1047 + int readLen = buf.writerIndex() - 0;
1300 - testupdateMsg = new byte[iReadLen]; 1048 + testupdateMsg = new byte[readLen];
1301 - buf.readBytes(testupdateMsg, 0, iReadLen); 1049 + buf.readBytes(testupdateMsg, 0, readLen);
1302 1050
1303 - if (Arrays.equals(updateMsg, testupdateMsg)) { 1051 + Assert.assertArrayEquals("PcUpd messages are not equal", updateMsg, testupdateMsg);
1304 - Assert.assertArrayEquals(updateMsg, testupdateMsg);
1305 - log.debug("updateMsg are equal :" + updateMsg);
1306 - } else {
1307 - Assert.fail("test case failed");
1308 - log.debug("not equal");
1309 - }
1310 - } else {
1311 - Assert.fail("test case failed");
1312 - log.debug("not equal");
1313 - }
1314 } 1052 }
1315 1053
1054 + /**
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 + */
1316 @Test 1060 @Test
1317 public void pcepUpdateMsgTest25() throws PcepParseException { 1061 public void pcepUpdateMsgTest25() throws PcepParseException {
1318 1062
1319 - /* Srp, Lsp (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv)
1320 - * Ero (IPv4SubObject, IPv4SubObject), Lspa, Bandwidth, Metric Object
1321 - */
1322 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x70, 1063 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x70,
1323 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object 1064 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
1324 0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x10, 0x03, //LSP object 1065 0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x10, 0x03, //LSP object
...@@ -1340,40 +1081,31 @@ public class PcepUpdateMsgTest { ...@@ -1340,40 +1081,31 @@ public class PcepUpdateMsgTest {
1340 1081
1341 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); 1082 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
1342 PcepMessage message = null; 1083 PcepMessage message = null;
1343 - try { 1084 +
1344 message = reader.readFrom(buffer); 1085 message = reader.readFrom(buffer);
1345 - } catch (PcepParseException e) {
1346 - e.printStackTrace();
1347 - }
1348 1086
1349 - if (message instanceof PcepUpdateMsg) { 1087 + Assert.assertTrue("PcepMessage is not instance of PcUpd", (message instanceof PcepUpdateMsg));
1350 ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); 1088 ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
1351 message.writeTo(buf); 1089 message.writeTo(buf);
1352 testupdateMsg = buf.array(); 1090 testupdateMsg = buf.array();
1353 1091
1354 - int iReadLen = buf.writerIndex() - 0; 1092 + int readLen = buf.writerIndex() - 0;
1355 - testupdateMsg = new byte[iReadLen]; 1093 + testupdateMsg = new byte[readLen];
1356 - buf.readBytes(testupdateMsg, 0, iReadLen); 1094 + buf.readBytes(testupdateMsg, 0, readLen);
1357 1095
1358 - if (Arrays.equals(updateMsg, testupdateMsg)) { 1096 + Assert.assertArrayEquals("PcUpd messages are not equal", updateMsg, testupdateMsg);
1359 - Assert.assertArrayEquals(updateMsg, testupdateMsg);
1360 - log.debug("updateMsg are equal :" + updateMsg);
1361 - } else {
1362 - Assert.fail("test case failed");
1363 - log.debug("not equal");
1364 - }
1365 - } else {
1366 - Assert.fail("test case failed");
1367 - log.debug("not equal");
1368 - }
1369 } 1097 }
1370 1098
1099 + /**
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 + */
1371 @Test 1106 @Test
1372 public void pcepUpdateMsgTest26() throws PcepParseException { 1107 public void pcepUpdateMsgTest26() throws PcepParseException {
1373 1108
1374 - /* Srp, Lsp (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv, StatefulLspErrorCodeTlv)
1375 - * Ero (IPv4SubObject, IPv4SubObject), Lspa, Bandwidth, Metric Object
1376 - */
1377 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x78, 1109 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x78,
1378 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object 1110 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
1379 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object 1111 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object
...@@ -1396,40 +1128,30 @@ public class PcepUpdateMsgTest { ...@@ -1396,40 +1128,30 @@ public class PcepUpdateMsgTest {
1396 1128
1397 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); 1129 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
1398 PcepMessage message = null; 1130 PcepMessage message = null;
1399 - try {
1400 - message = reader.readFrom(buffer);
1401 - } catch (PcepParseException e) {
1402 - e.printStackTrace();
1403 - }
1404 1131
1405 - if (message instanceof PcepUpdateMsg) { 1132 + message = reader.readFrom(buffer);
1133 + Assert.assertTrue("PcepMessage is not instance of PcUpd", (message instanceof PcepUpdateMsg));
1406 ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); 1134 ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
1407 message.writeTo(buf); 1135 message.writeTo(buf);
1408 testupdateMsg = buf.array(); 1136 testupdateMsg = buf.array();
1409 1137
1410 - int iReadLen = buf.writerIndex() - 0; 1138 + int readLen = buf.writerIndex() - 0;
1411 - testupdateMsg = new byte[iReadLen]; 1139 + testupdateMsg = new byte[readLen];
1412 - buf.readBytes(testupdateMsg, 0, iReadLen); 1140 + buf.readBytes(testupdateMsg, 0, readLen);
1413 1141
1414 - if (Arrays.equals(updateMsg, testupdateMsg)) { 1142 + Assert.assertArrayEquals("PcUpd messages are not equal", updateMsg, testupdateMsg);
1415 - Assert.assertArrayEquals(updateMsg, testupdateMsg);
1416 - log.debug("updateMsg are equal :" + updateMsg);
1417 - } else {
1418 - Assert.fail("test case failed");
1419 - log.debug("not equal");
1420 - }
1421 - } else {
1422 - Assert.fail("test case failed");
1423 - log.debug("not equal");
1424 - }
1425 } 1143 }
1426 1144
1145 + /**
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 + */
1427 @Test 1152 @Test
1428 public void pcepUpdateMsgTest27() throws PcepParseException { 1153 public void pcepUpdateMsgTest27() throws PcepParseException {
1429 1154
1430 - /* Srp, Lsp (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv, StatefulLspErrorCodeTlv)
1431 - * Ero (IPv4SubObject, IPv4SubObject), Lspa, Bandwidth, Metric Object
1432 - */
1433 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x78, 1155 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x78,
1434 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object 1156 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
1435 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object 1157 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object
...@@ -1452,40 +1174,31 @@ public class PcepUpdateMsgTest { ...@@ -1452,40 +1174,31 @@ public class PcepUpdateMsgTest {
1452 1174
1453 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); 1175 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
1454 PcepMessage message = null; 1176 PcepMessage message = null;
1455 - try { 1177 +
1456 message = reader.readFrom(buffer); 1178 message = reader.readFrom(buffer);
1457 - } catch (PcepParseException e) {
1458 - e.printStackTrace();
1459 - }
1460 1179
1461 - if (message instanceof PcepUpdateMsg) { 1180 + Assert.assertTrue("PcepMessage is not instance of PcUpd", (message instanceof PcepUpdateMsg));
1462 ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); 1181 ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
1463 message.writeTo(buf); 1182 message.writeTo(buf);
1464 testupdateMsg = buf.array(); 1183 testupdateMsg = buf.array();
1465 1184
1466 - int iReadLen = buf.writerIndex() - 0; 1185 + int readLen = buf.writerIndex() - 0;
1467 - testupdateMsg = new byte[iReadLen]; 1186 + testupdateMsg = new byte[readLen];
1468 - buf.readBytes(testupdateMsg, 0, iReadLen); 1187 + buf.readBytes(testupdateMsg, 0, readLen);
1469 1188
1470 - if (Arrays.equals(updateMsg, testupdateMsg)) { 1189 + Assert.assertArrayEquals("PcUpd messages are not equal", updateMsg, testupdateMsg);
1471 - Assert.assertArrayEquals(updateMsg, testupdateMsg);
1472 - log.debug("updateMsg are equal :" + updateMsg);
1473 - } else {
1474 - Assert.fail("test case failed");
1475 - log.debug("not equal");
1476 - }
1477 - } else {
1478 - Assert.fail("test case failed");
1479 - log.debug("not equal");
1480 - }
1481 } 1190 }
1482 1191
1192 + /**
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 + */
1483 @Test 1199 @Test
1484 public void pcepUpdateMsgTest28() throws PcepParseException { 1200 public void pcepUpdateMsgTest28() throws PcepParseException {
1485 1201
1486 - /* Srp, Lsp (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv,
1487 - * StatefulLspErrorCodeTlv), Ero (IPv4SubObject, IPv4SubObject), Lspa, Bandwidth, Metric Object
1488 - */
1489 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x80, 1202 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x80,
1490 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object 1203 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
1491 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv 1204 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
...@@ -1509,40 +1222,30 @@ public class PcepUpdateMsgTest { ...@@ -1509,40 +1222,30 @@ public class PcepUpdateMsgTest {
1509 1222
1510 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); 1223 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
1511 PcepMessage message = null; 1224 PcepMessage message = null;
1512 - try { 1225 +
1513 message = reader.readFrom(buffer); 1226 message = reader.readFrom(buffer);
1514 - } catch (PcepParseException e) {
1515 - e.printStackTrace();
1516 - }
1517 1227
1518 - if (message instanceof PcepUpdateMsg) { 1228 + Assert.assertTrue("PcepMessage is not instance of PcUpd", (message instanceof PcepUpdateMsg));
1519 ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); 1229 ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
1520 message.writeTo(buf); 1230 message.writeTo(buf);
1521 testupdateMsg = buf.array(); 1231 testupdateMsg = buf.array();
1522 1232
1523 - int iReadLen = buf.writerIndex() - 0; 1233 + int readLen = buf.writerIndex() - 0;
1524 - testupdateMsg = new byte[iReadLen]; 1234 + testupdateMsg = new byte[readLen];
1525 - buf.readBytes(testupdateMsg, 0, iReadLen); 1235 + buf.readBytes(testupdateMsg, 0, readLen);
1526 1236
1527 - if (Arrays.equals(updateMsg, testupdateMsg)) { 1237 + Assert.assertArrayEquals("PcUpd messages are not equal", updateMsg, testupdateMsg);
1528 - Assert.assertArrayEquals(updateMsg, testupdateMsg);
1529 - log.debug("updateMsg are equal :" + updateMsg);
1530 - } else {
1531 - Assert.fail("test case failed");
1532 - log.debug("not equal");
1533 - }
1534 - } else {
1535 - Assert.fail("test case failed");
1536 - log.debug("not equal");
1537 - }
1538 } 1238 }
1539 1239
1240 + /**
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 + */
1540 @Test 1246 @Test
1541 public void pcepUpdateMsgTest29() throws PcepParseException { 1247 public void pcepUpdateMsgTest29() throws PcepParseException {
1542 1248
1543 - /* Srp, Lsp (StatefulIPv4LspIdentidiersTlv),
1544 - * Ero (IPv4SubObject, IPv4SubObject), Lspa, Bandwidth, Metric Object
1545 - */
1546 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x68, 1249 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x68,
1547 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object 1250 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
1548 0x20, 0x10, 0x00, 0x1C, 0x00, 0x00, 0x10, 0x03, //LSP object 1251 0x20, 0x10, 0x00, 0x1C, 0x00, 0x00, 0x10, 0x03, //LSP object
...@@ -1563,40 +1266,30 @@ public class PcepUpdateMsgTest { ...@@ -1563,40 +1266,30 @@ public class PcepUpdateMsgTest {
1563 1266
1564 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); 1267 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
1565 PcepMessage message = null; 1268 PcepMessage message = null;
1566 - try { 1269 +
1567 message = reader.readFrom(buffer); 1270 message = reader.readFrom(buffer);
1568 - } catch (PcepParseException e) {
1569 - e.printStackTrace();
1570 - }
1571 1271
1572 - if (message instanceof PcepUpdateMsg) { 1272 + Assert.assertTrue("PcepMessage is not instance of PcUpd", (message instanceof PcepUpdateMsg));
1573 ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); 1273 ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
1574 message.writeTo(buf); 1274 message.writeTo(buf);
1575 testupdateMsg = buf.array(); 1275 testupdateMsg = buf.array();
1576 1276
1577 - int iReadLen = buf.writerIndex() - 0; 1277 + int readLen = buf.writerIndex() - 0;
1578 - testupdateMsg = new byte[iReadLen]; 1278 + testupdateMsg = new byte[readLen];
1579 - buf.readBytes(testupdateMsg, 0, iReadLen); 1279 + buf.readBytes(testupdateMsg, 0, readLen);
1580 1280
1581 - if (Arrays.equals(updateMsg, testupdateMsg)) { 1281 + Assert.assertArrayEquals("PcUpd messages are not equal", updateMsg, testupdateMsg);
1582 - Assert.assertArrayEquals(updateMsg, testupdateMsg);
1583 - log.debug("updateMsg are equal :" + updateMsg);
1584 - } else {
1585 - Assert.fail("test case failed");
1586 - log.debug("not equal");
1587 - }
1588 - } else {
1589 - Assert.fail("test case failed");
1590 - log.debug("not equal");
1591 - }
1592 } 1282 }
1593 1283
1284 + /**
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 + */
1594 @Test 1290 @Test
1595 public void pcepUpdateMsgTest30() throws PcepParseException { 1291 public void pcepUpdateMsgTest30() throws PcepParseException {
1596 1292
1597 - /* Srp, Lsp ,
1598 - * Ero (IPv4SubObject, IPv4SubObject), Lspa, Bandwidth, Metric Object
1599 - */
1600 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x54, 1293 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x54,
1601 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object 1294 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
1602 0x20, 0x10, 0x00, 0x08, 0x00, 0x00, 0x10, 0x03, //LSP object 1295 0x20, 0x10, 0x00, 0x08, 0x00, 0x00, 0x10, 0x03, //LSP object
...@@ -1614,40 +1307,30 @@ public class PcepUpdateMsgTest { ...@@ -1614,40 +1307,30 @@ public class PcepUpdateMsgTest {
1614 1307
1615 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); 1308 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
1616 PcepMessage message = null; 1309 PcepMessage message = null;
1617 - try { 1310 +
1618 message = reader.readFrom(buffer); 1311 message = reader.readFrom(buffer);
1619 - } catch (PcepParseException e) {
1620 - e.printStackTrace();
1621 - }
1622 1312
1623 - if (message instanceof PcepUpdateMsg) { 1313 + Assert.assertTrue("PcepMessage is not instance of PcUpd", (message instanceof PcepUpdateMsg));
1624 ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); 1314 ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
1625 message.writeTo(buf); 1315 message.writeTo(buf);
1626 testupdateMsg = buf.array(); 1316 testupdateMsg = buf.array();
1627 1317
1628 - int iReadLen = buf.writerIndex() - 0; 1318 + int readLen = buf.writerIndex() - 0;
1629 - testupdateMsg = new byte[iReadLen]; 1319 + testupdateMsg = new byte[readLen];
1630 - buf.readBytes(testupdateMsg, 0, iReadLen); 1320 + buf.readBytes(testupdateMsg, 0, readLen);
1631 1321
1632 - if (Arrays.equals(updateMsg, testupdateMsg)) { 1322 + Assert.assertArrayEquals("PcUpd messages are not equal", updateMsg, testupdateMsg);
1633 - Assert.assertArrayEquals(updateMsg, testupdateMsg);
1634 - log.debug("updateMsg are equal :" + updateMsg);
1635 - } else {
1636 - Assert.fail("test case failed");
1637 - log.debug("not equal");
1638 - }
1639 - } else {
1640 - Assert.fail("test case failed");
1641 - log.debug("not equal");
1642 - }
1643 } 1323 }
1644 1324
1325 + /**
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 + */
1645 @Test 1331 @Test
1646 public void pcepUpdateMsgTest31() throws PcepParseException { 1332 public void pcepUpdateMsgTest31() throws PcepParseException {
1647 1333
1648 - /* Srp, Lsp (StatefulLspErrorCodeTlv),
1649 - * Ero (IPv4SubObject, IPv4SubObject), Lspa, Bandwidth, Metric Object
1650 - */
1651 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x5c, 1334 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x5c,
1652 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object 1335 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
1653 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object 1336 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
...@@ -1666,40 +1349,30 @@ public class PcepUpdateMsgTest { ...@@ -1666,40 +1349,30 @@ public class PcepUpdateMsgTest {
1666 1349
1667 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); 1350 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
1668 PcepMessage message = null; 1351 PcepMessage message = null;
1669 - try { 1352 +
1670 message = reader.readFrom(buffer); 1353 message = reader.readFrom(buffer);
1671 - } catch (PcepParseException e) {
1672 - e.printStackTrace();
1673 - }
1674 1354
1675 - if (message instanceof PcepUpdateMsg) { 1355 + Assert.assertTrue("PcepMessage is not instance of PcUpd", (message instanceof PcepUpdateMsg));
1676 ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); 1356 ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
1677 message.writeTo(buf); 1357 message.writeTo(buf);
1678 testupdateMsg = buf.array(); 1358 testupdateMsg = buf.array();
1679 1359
1680 - int iReadLen = buf.writerIndex() - 0; 1360 + int readLen = buf.writerIndex() - 0;
1681 - testupdateMsg = new byte[iReadLen]; 1361 + testupdateMsg = new byte[readLen];
1682 - buf.readBytes(testupdateMsg, 0, iReadLen); 1362 + buf.readBytes(testupdateMsg, 0, readLen);
1683 1363
1684 - if (Arrays.equals(updateMsg, testupdateMsg)) { 1364 + Assert.assertArrayEquals("PcUpd messages are not equal", updateMsg, testupdateMsg);
1685 - Assert.assertArrayEquals(updateMsg, testupdateMsg);
1686 - log.debug("updateMsg are equal :" + updateMsg);
1687 - } else {
1688 - Assert.fail("test case failed");
1689 - log.debug("not equal");
1690 - }
1691 - } else {
1692 - Assert.fail("test case failed");
1693 - log.debug("not equal");
1694 - }
1695 } 1365 }
1696 1366
1367 + /**
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 + */
1697 @Test 1373 @Test
1698 public void pcepUpdateMsgTest32() throws PcepParseException { 1374 public void pcepUpdateMsgTest32() throws PcepParseException {
1699 1375
1700 - /* Srp, Lsp,
1701 - * Ero (IPv4SubObject, IPv4SubObject), Lspa, Bandwidth, Metric Object
1702 - */
1703 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x54, 1376 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x54,
1704 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object 1377 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
1705 0x20, 0x10, 0x00, 0x8, 0x00, 0x00, 0x10, 0x03, //LSP object 1378 0x20, 0x10, 0x00, 0x8, 0x00, 0x00, 0x10, 0x03, //LSP object
...@@ -1717,40 +1390,30 @@ public class PcepUpdateMsgTest { ...@@ -1717,40 +1390,30 @@ public class PcepUpdateMsgTest {
1717 1390
1718 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); 1391 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
1719 PcepMessage message = null; 1392 PcepMessage message = null;
1720 - try { 1393 +
1721 message = reader.readFrom(buffer); 1394 message = reader.readFrom(buffer);
1722 - } catch (PcepParseException e) {
1723 - e.printStackTrace();
1724 - }
1725 1395
1726 - if (message instanceof PcepUpdateMsg) { 1396 + Assert.assertTrue("PcepMessage is not instance of PcUpd", (message instanceof PcepUpdateMsg));
1727 ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); 1397 ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
1728 message.writeTo(buf); 1398 message.writeTo(buf);
1729 testupdateMsg = buf.array(); 1399 testupdateMsg = buf.array();
1730 1400
1731 - int iReadLen = buf.writerIndex() - 0; 1401 + int readLen = buf.writerIndex() - 0;
1732 - testupdateMsg = new byte[iReadLen]; 1402 + testupdateMsg = new byte[readLen];
1733 - buf.readBytes(testupdateMsg, 0, iReadLen); 1403 + buf.readBytes(testupdateMsg, 0, readLen);
1734 1404
1735 - if (Arrays.equals(updateMsg, testupdateMsg)) { 1405 + Assert.assertArrayEquals("PcUpd messages are not equal", updateMsg, testupdateMsg);
1736 - Assert.assertArrayEquals(updateMsg, testupdateMsg);
1737 - log.debug("updateMsg are equal :" + updateMsg);
1738 - } else {
1739 - Assert.fail("test case failed");
1740 - log.debug("not equal");
1741 - }
1742 - } else {
1743 - Assert.fail("test case failed");
1744 - log.debug("not equal");
1745 - }
1746 } 1406 }
1747 1407
1408 + /**
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 + */
1748 @Test 1414 @Test
1749 public void pcepUpdateMsgTest33() throws PcepParseException { 1415 public void pcepUpdateMsgTest33() throws PcepParseException {
1750 1416
1751 - /* Srp, Lsp (SymbolicPathNameTlv),
1752 - * Ero (IPv4SubObject, IPv4SubObject), Lspa, Bandwidth, Metric Object
1753 - */
1754 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x5c, 1417 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x5c,
1755 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object 1418 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
1756 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object 1419 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
...@@ -1769,40 +1432,30 @@ public class PcepUpdateMsgTest { ...@@ -1769,40 +1432,30 @@ public class PcepUpdateMsgTest {
1769 1432
1770 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); 1433 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
1771 PcepMessage message = null; 1434 PcepMessage message = null;
1772 - try { 1435 +
1773 message = reader.readFrom(buffer); 1436 message = reader.readFrom(buffer);
1774 - } catch (PcepParseException e) {
1775 - e.printStackTrace();
1776 - }
1777 1437
1778 - if (message instanceof PcepUpdateMsg) { 1438 + Assert.assertTrue("PcepMessage is not instance of PcUpd", (message instanceof PcepUpdateMsg));
1779 ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); 1439 ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
1780 message.writeTo(buf); 1440 message.writeTo(buf);
1781 testupdateMsg = buf.array(); 1441 testupdateMsg = buf.array();
1782 1442
1783 - int iReadLen = buf.writerIndex() - 0; 1443 + int readLen = buf.writerIndex() - 0;
1784 - testupdateMsg = new byte[iReadLen]; 1444 + testupdateMsg = new byte[readLen];
1785 - buf.readBytes(testupdateMsg, 0, iReadLen); 1445 + buf.readBytes(testupdateMsg, 0, readLen);
1786 1446
1787 - if (Arrays.equals(updateMsg, testupdateMsg)) { 1447 + Assert.assertArrayEquals("PcUpd messages are not equal", updateMsg, testupdateMsg);
1788 - Assert.assertArrayEquals(updateMsg, testupdateMsg);
1789 - log.debug("updateMsg are equal :" + updateMsg);
1790 - } else {
1791 - Assert.fail("test case failed");
1792 - log.debug("not equal");
1793 - }
1794 - } else {
1795 - Assert.fail("test case failed");
1796 - log.debug("not equal");
1797 - }
1798 } 1448 }
1799 1449
1450 + /**
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 + */
1800 @Test 1456 @Test
1801 public void pcepUpdateMsgTest34() throws PcepParseException { 1457 public void pcepUpdateMsgTest34() throws PcepParseException {
1802 1458
1803 - /* Srp, Lsp (SymbolicPathNameTlv, SymbolicPathNameTlv),
1804 - * Ero (IPv4SubObject, IPv4SubObject), Lspa, Bandwidth, Metric Object
1805 - */
1806 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x64, 1459 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x64,
1807 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object 1460 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
1808 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv 1461 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
...@@ -1822,31 +1475,18 @@ public class PcepUpdateMsgTest { ...@@ -1822,31 +1475,18 @@ public class PcepUpdateMsgTest {
1822 1475
1823 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); 1476 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
1824 PcepMessage message = null; 1477 PcepMessage message = null;
1825 - try { 1478 +
1826 message = reader.readFrom(buffer); 1479 message = reader.readFrom(buffer);
1827 - } catch (PcepParseException e) {
1828 - e.printStackTrace();
1829 - }
1830 1480
1831 - if (message instanceof PcepUpdateMsg) { 1481 + Assert.assertTrue("PcepMessage is not instance of PcUpd", (message instanceof PcepUpdateMsg));
1832 ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); 1482 ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
1833 message.writeTo(buf); 1483 message.writeTo(buf);
1834 testupdateMsg = buf.array(); 1484 testupdateMsg = buf.array();
1835 1485
1836 - int iReadLen = buf.writerIndex() - 0; 1486 + int readLen = buf.writerIndex() - 0;
1837 - testupdateMsg = new byte[iReadLen]; 1487 + testupdateMsg = new byte[readLen];
1838 - buf.readBytes(testupdateMsg, 0, iReadLen); 1488 + buf.readBytes(testupdateMsg, 0, readLen);
1839 1489
1840 - if (Arrays.equals(updateMsg, testupdateMsg)) { 1490 + Assert.assertArrayEquals("PcUpd messages are not equal", updateMsg, testupdateMsg);
1841 - Assert.assertArrayEquals(updateMsg, testupdateMsg);
1842 - log.debug("updateMsg are equal :" + updateMsg);
1843 - } else {
1844 - Assert.fail("test case failed");
1845 - log.debug("not equal");
1846 - }
1847 - } else {
1848 - Assert.fail("test case failed");
1849 - log.debug("not equal");
1850 - }
1851 } 1491 }
1852 } 1492 }
......
...@@ -17,9 +17,7 @@ package org.onosproject.pcepio; ...@@ -17,9 +17,7 @@ package org.onosproject.pcepio;
17 17
18 import org.jboss.netty.buffer.ChannelBuffer; 18 import org.jboss.netty.buffer.ChannelBuffer;
19 import org.jboss.netty.buffer.ChannelBuffers; 19 import org.jboss.netty.buffer.ChannelBuffers;
20 -import org.junit.After;
21 import org.junit.Assert; 20 import org.junit.Assert;
22 -import org.junit.Before;
23 import org.junit.Test; 21 import org.junit.Test;
24 import org.onosproject.pcepio.exceptions.PcepParseException; 22 import org.onosproject.pcepio.exceptions.PcepParseException;
25 import org.onosproject.pcepio.protocol.PcepFactories; 23 import org.onosproject.pcepio.protocol.PcepFactories;
...@@ -27,27 +25,17 @@ import org.onosproject.pcepio.protocol.PcepMessage; ...@@ -27,27 +25,17 @@ import org.onosproject.pcepio.protocol.PcepMessage;
27 import org.onosproject.pcepio.protocol.PcepMessageReader; 25 import org.onosproject.pcepio.protocol.PcepMessageReader;
28 import org.onosproject.pcepio.protocol.PcepUpdateMsg; 26 import org.onosproject.pcepio.protocol.PcepUpdateMsg;
29 27
30 -import java.util.Arrays;
31 -
32 -import org.slf4j.Logger;
33 -import org.slf4j.LoggerFactory;
34 -
35 /** 28 /**
36 * Test cases for PCEP update message. 29 * Test cases for PCEP update message.
37 */ 30 */
38 public class PcepUpdateMsgTest2 { 31 public class PcepUpdateMsgTest2 {
39 32
40 - protected static final Logger log = LoggerFactory.getLogger(PcepUpdateMsgTest2.class); 33 + /**
41 - 34 + * This test case is for SRP object(symbolic path tlv), LSP object(StatefulLspDbVerTlv), ERO object,
42 - @Before 35 + * Metric object in PcepUpdate message.
43 - public void startUp() { 36 + *
44 - } 37 + * @throws PcepParseException while parsing PCEP message
45 - 38 + */
46 - @After
47 - public void tearDown() {
48 -
49 - }
50 -
51 @Test 39 @Test
52 public void pcepUpdateMsgTest1() throws PcepParseException { 40 public void pcepUpdateMsgTest1() throws PcepParseException {
53 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x8c, 41 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x8c,
...@@ -75,34 +63,27 @@ public class PcepUpdateMsgTest2 { ...@@ -75,34 +63,27 @@ public class PcepUpdateMsgTest2 {
75 63
76 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); 64 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
77 PcepMessage message = null; 65 PcepMessage message = null;
78 - try { 66 +
79 message = reader.readFrom(buffer); 67 message = reader.readFrom(buffer);
80 - } catch (PcepParseException e) { 68 + Assert.assertTrue("PcepMessage is not instance of PcepUpdateMsg", message instanceof PcepUpdateMsg);
81 - e.printStackTrace();
82 - }
83 69
84 - if (message instanceof PcepUpdateMsg) {
85 ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); 70 ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
86 message.writeTo(buf); 71 message.writeTo(buf);
87 testupdateMsg = buf.array(); 72 testupdateMsg = buf.array();
88 73
89 - int iReadLen = buf.writerIndex() - 0; 74 + int readLen = buf.writerIndex() - 0;
90 - testupdateMsg = new byte[iReadLen]; 75 + testupdateMsg = new byte[readLen];
91 - buf.readBytes(testupdateMsg, 0, iReadLen); 76 + buf.readBytes(testupdateMsg, 0, readLen);
92 77
93 - if (Arrays.equals(updateMsg, testupdateMsg)) { 78 + Assert.assertArrayEquals("PcepUpdatemsg messages are not equal", updateMsg, testupdateMsg);
94 - Assert.assertArrayEquals(updateMsg, testupdateMsg);
95 - log.debug("updateMsg are equal :" + updateMsg);
96 - } else {
97 - Assert.fail("test case failed");
98 - log.debug("not equal");
99 - }
100 - } else {
101 - Assert.fail("test case failed");
102 - log.debug("not equal");
103 - }
104 } 79 }
105 80
81 + /**
82 + * This test case is for SRP object, LSP object(StatefulIPv4LspIdentidiersTlv), ERO object,
83 + * LSPA, Bandwidth object in PcepUpdate message.
84 + *
85 + * @throws PcepParseException while parsing PCEP message
86 + */
106 @Test 87 @Test
107 public void pcepUpdateMsgTest2() throws PcepParseException { 88 public void pcepUpdateMsgTest2() throws PcepParseException {
108 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x68, 89 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x68,
...@@ -125,34 +106,27 @@ public class PcepUpdateMsgTest2 { ...@@ -125,34 +106,27 @@ public class PcepUpdateMsgTest2 {
125 106
126 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); 107 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
127 PcepMessage message = null; 108 PcepMessage message = null;
128 - try { 109 +
129 message = reader.readFrom(buffer); 110 message = reader.readFrom(buffer);
130 - } catch (PcepParseException e) {
131 - e.printStackTrace();
132 - }
133 111
134 - if (message instanceof PcepUpdateMsg) { 112 + Assert.assertTrue("PcepMessage is not instance of PcepUpdateMsg", message instanceof PcepUpdateMsg);
135 ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); 113 ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
136 message.writeTo(buf); 114 message.writeTo(buf);
137 testupdateMsg = buf.array(); 115 testupdateMsg = buf.array();
138 116
139 - int iReadLen = buf.writerIndex() - 0; 117 + int readLen = buf.writerIndex() - 0;
140 - testupdateMsg = new byte[iReadLen]; 118 + testupdateMsg = new byte[readLen];
141 - buf.readBytes(testupdateMsg, 0, iReadLen); 119 + buf.readBytes(testupdateMsg, 0, readLen);
142 120
143 - if (Arrays.equals(updateMsg, testupdateMsg)) { 121 + Assert.assertArrayEquals("PcepUpdatemsg messages are not equal", updateMsg, testupdateMsg);
144 - Assert.assertArrayEquals(updateMsg, testupdateMsg);
145 - log.debug("updateMsg are equal :" + updateMsg);
146 - } else {
147 - Assert.fail("test case failed");
148 - log.debug("not equal");
149 - }
150 - } else {
151 - Assert.fail("test case failed");
152 - log.debug("not equal");
153 - }
154 } 122 }
155 123
124 + /**
125 + * This test case is for SRP object, LSP object, ERO object, LSPA, bandwidth object
126 + * Metric object in PcepUpdate message.
127 + *
128 + * @throws PcepParseException while parsing PCEP message
129 + */
156 @Test 130 @Test
157 public void pcepUpdateMsgTest3() throws PcepParseException { 131 public void pcepUpdateMsgTest3() throws PcepParseException {
158 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x54, 132 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x54,
...@@ -172,34 +146,27 @@ public class PcepUpdateMsgTest2 { ...@@ -172,34 +146,27 @@ public class PcepUpdateMsgTest2 {
172 146
173 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); 147 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
174 PcepMessage message = null; 148 PcepMessage message = null;
175 - try { 149 +
176 message = reader.readFrom(buffer); 150 message = reader.readFrom(buffer);
177 - } catch (PcepParseException e) {
178 - e.printStackTrace();
179 - }
180 151
181 - if (message instanceof PcepUpdateMsg) { 152 + Assert.assertTrue("PcepMessage is not instance of PcepUpdateMsg", message instanceof PcepUpdateMsg);
182 ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); 153 ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
183 message.writeTo(buf); 154 message.writeTo(buf);
184 testupdateMsg = buf.array(); 155 testupdateMsg = buf.array();
185 156
186 - int iReadLen = buf.writerIndex() - 0; 157 + int readLen = buf.writerIndex() - 0;
187 - testupdateMsg = new byte[iReadLen]; 158 + testupdateMsg = new byte[readLen];
188 - buf.readBytes(testupdateMsg, 0, iReadLen); 159 + buf.readBytes(testupdateMsg, 0, readLen);
189 160
190 - if (Arrays.equals(updateMsg, testupdateMsg)) { 161 + Assert.assertArrayEquals("PcepUpdatemsg messages are not equal", updateMsg, testupdateMsg);
191 - Assert.assertArrayEquals(updateMsg, testupdateMsg);
192 - log.debug("updateMsg are equal :" + updateMsg);
193 - } else {
194 - Assert.fail("test case failed");
195 - log.debug("not equal");
196 - }
197 - } else {
198 - Assert.fail("test case failed");
199 - log.debug("not equal");
200 - }
201 } 162 }
202 163
164 + /**
165 + * This test case is for SRP object, LSP object(StatefulLspErrorCodeTlv), ERO object,bandwidth object
166 + * Metric object in PcepUpdate message.
167 + *
168 + * @throws PcepParseException while parsing PCEP message
169 + */
203 @Test 170 @Test
204 public void pcepUpdateMsgTest4() throws PcepParseException { 171 public void pcepUpdateMsgTest4() throws PcepParseException {
205 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x5c, 172 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x5c,
...@@ -220,34 +187,27 @@ public class PcepUpdateMsgTest2 { ...@@ -220,34 +187,27 @@ public class PcepUpdateMsgTest2 {
220 187
221 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); 188 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
222 PcepMessage message = null; 189 PcepMessage message = null;
223 - try { 190 +
224 message = reader.readFrom(buffer); 191 message = reader.readFrom(buffer);
225 - } catch (PcepParseException e) {
226 - e.printStackTrace();
227 - }
228 192
229 - if (message instanceof PcepUpdateMsg) { 193 + Assert.assertTrue("PcepMessage is not instance of PcepUpdateMsg", message instanceof PcepUpdateMsg);
230 ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); 194 ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
231 message.writeTo(buf); 195 message.writeTo(buf);
232 testupdateMsg = buf.array(); 196 testupdateMsg = buf.array();
233 197
234 - int iReadLen = buf.writerIndex() - 0; 198 + int readLen = buf.writerIndex() - 0;
235 - testupdateMsg = new byte[iReadLen]; 199 + testupdateMsg = new byte[readLen];
236 - buf.readBytes(testupdateMsg, 0, iReadLen); 200 + buf.readBytes(testupdateMsg, 0, readLen);
237 201
238 - if (Arrays.equals(updateMsg, testupdateMsg)) { 202 + Assert.assertArrayEquals("PcepUpdatemsg messages are not equal", updateMsg, testupdateMsg);
239 - Assert.assertArrayEquals(updateMsg, testupdateMsg);
240 - log.debug("updateMsg are equal :" + updateMsg);
241 - } else {
242 - Assert.fail("test case failed");
243 - log.debug("not equal");
244 - }
245 - } else {
246 - Assert.fail("test case failed");
247 - log.debug("not equal");
248 - }
249 } 203 }
250 204
205 + /**
206 + * This test case is for SRP object, LSP object(StatefulLspDbVerTlv), ERO object,bandwidth object
207 + * Metric object in PcepUpdate message.
208 + *
209 + * @throws PcepParseException while parsing PCEP message
210 + */
251 @Test 211 @Test
252 public void pcepUpdateMsgTest5() throws PcepParseException { 212 public void pcepUpdateMsgTest5() throws PcepParseException {
253 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x60, 213 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x60,
...@@ -269,34 +229,27 @@ public class PcepUpdateMsgTest2 { ...@@ -269,34 +229,27 @@ public class PcepUpdateMsgTest2 {
269 229
270 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); 230 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
271 PcepMessage message = null; 231 PcepMessage message = null;
272 - try { 232 +
273 message = reader.readFrom(buffer); 233 message = reader.readFrom(buffer);
274 - } catch (PcepParseException e) {
275 - e.printStackTrace();
276 - }
277 234
278 - if (message instanceof PcepUpdateMsg) { 235 + Assert.assertTrue("PcepMessage is not instance of PcepUpdateMsg", message instanceof PcepUpdateMsg);
279 ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); 236 ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
280 message.writeTo(buf); 237 message.writeTo(buf);
281 testupdateMsg = buf.array(); 238 testupdateMsg = buf.array();
282 239
283 - int iReadLen = buf.writerIndex() - 0; 240 + int readLen = buf.writerIndex() - 0;
284 - testupdateMsg = new byte[iReadLen]; 241 + testupdateMsg = new byte[readLen];
285 - buf.readBytes(testupdateMsg, 0, iReadLen); 242 + buf.readBytes(testupdateMsg, 0, readLen);
286 243
287 - if (Arrays.equals(updateMsg, testupdateMsg)) { 244 + Assert.assertArrayEquals("PcepUpdatemsg messages are not equal", updateMsg, testupdateMsg);
288 - Assert.assertArrayEquals(updateMsg, testupdateMsg);
289 - log.debug("updateMsg are equal :" + updateMsg);
290 - } else {
291 - Assert.fail("test case failed");
292 - log.debug("not equal");
293 - }
294 - } else {
295 - Assert.fail("test case failed");
296 - log.debug("not equal");
297 - }
298 } 245 }
299 246
247 + /**
248 + * This test case is for SRP object, LSP object(SymbolicPathNameTlv), ERO object, LSPA, bandwidth object
249 + * Metric object in PcepUpdate message.
250 + *
251 + * @throws PcepParseException while parsing PCEP message
252 + */
300 @Test 253 @Test
301 public void pcepUpdateMsgTest6() throws PcepParseException { 254 public void pcepUpdateMsgTest6() throws PcepParseException {
302 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x5c, 255 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x5c,
...@@ -317,34 +270,27 @@ public class PcepUpdateMsgTest2 { ...@@ -317,34 +270,27 @@ public class PcepUpdateMsgTest2 {
317 270
318 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); 271 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
319 PcepMessage message = null; 272 PcepMessage message = null;
320 - try { 273 +
321 message = reader.readFrom(buffer); 274 message = reader.readFrom(buffer);
322 - } catch (PcepParseException e) {
323 - e.printStackTrace();
324 - }
325 275
326 - if (message instanceof PcepUpdateMsg) { 276 + Assert.assertTrue("PcepMessage is not instance of PcepUpdateMsg", message instanceof PcepUpdateMsg);
327 ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); 277 ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
328 message.writeTo(buf); 278 message.writeTo(buf);
329 testupdateMsg = buf.array(); 279 testupdateMsg = buf.array();
330 280
331 - int iReadLen = buf.writerIndex() - 0; 281 + int readLen = buf.writerIndex() - 0;
332 - testupdateMsg = new byte[iReadLen]; 282 + testupdateMsg = new byte[readLen];
333 - buf.readBytes(testupdateMsg, 0, iReadLen); 283 + buf.readBytes(testupdateMsg, 0, readLen);
334 284
335 - if (Arrays.equals(updateMsg, testupdateMsg)) { 285 + Assert.assertArrayEquals("PcepUpdatemsg messages are not equal", updateMsg, testupdateMsg);
336 - Assert.assertArrayEquals(updateMsg, testupdateMsg);
337 - log.debug("updateMsg are equal :" + updateMsg);
338 - } else {
339 - Assert.fail("test case failed");
340 - log.debug("not equal");
341 - }
342 - } else {
343 - Assert.fail("test case failed");
344 - log.debug("not equal");
345 - }
346 } 286 }
347 287
288 + /**
289 + * This test case is for SRP object(SymbolicPathNameTlv), LSP object(SymbolicPathNameTlv), ERO object,
290 + * bandwidth object Metric object in PcepUpdate message.
291 + *
292 + * @throws PcepParseException while parsing PCEP message
293 + */
348 @Test 294 @Test
349 public void pcepUpdateMsgTest7() throws PcepParseException { 295 public void pcepUpdateMsgTest7() throws PcepParseException {
350 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x64, 296 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x64,
...@@ -366,34 +312,27 @@ public class PcepUpdateMsgTest2 { ...@@ -366,34 +312,27 @@ public class PcepUpdateMsgTest2 {
366 312
367 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); 313 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
368 PcepMessage message = null; 314 PcepMessage message = null;
369 - try { 315 +
370 message = reader.readFrom(buffer); 316 message = reader.readFrom(buffer);
371 - } catch (PcepParseException e) {
372 - e.printStackTrace();
373 - }
374 317
375 - if (message instanceof PcepUpdateMsg) { 318 + Assert.assertTrue("PcepMessage is not instance of PcepUpdateMsg", message instanceof PcepUpdateMsg);
376 ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); 319 ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
377 message.writeTo(buf); 320 message.writeTo(buf);
378 testupdateMsg = buf.array(); 321 testupdateMsg = buf.array();
379 322
380 - int iReadLen = buf.writerIndex() - 0; 323 + int readLen = buf.writerIndex() - 0;
381 - testupdateMsg = new byte[iReadLen]; 324 + testupdateMsg = new byte[readLen];
382 - buf.readBytes(testupdateMsg, 0, iReadLen); 325 + buf.readBytes(testupdateMsg, 0, readLen);
383 326
384 - if (Arrays.equals(updateMsg, testupdateMsg)) { 327 + Assert.assertArrayEquals("PcepUpdatemsg messages are not equal", updateMsg, testupdateMsg);
385 - Assert.assertArrayEquals(updateMsg, testupdateMsg);
386 - log.debug("updateMsg are equal :" + updateMsg);
387 - } else {
388 - Assert.fail("test case failed");
389 - log.debug("not equal");
390 - }
391 - } else {
392 - Assert.fail("test case failed");
393 - log.debug("not equal");
394 - }
395 } 328 }
396 329
330 + /**
331 + * This test case is for SRP object, LSP object(StatefulIPv4LspIdentidiersTlv), ERO object,LSPA
332 + * bandwidth object in PcepUpdate message.
333 + *
334 + * @throws PcepParseException while parsing PCEP message
335 + */
397 @Test 336 @Test
398 public void pcepUpdateMsgTest8() throws PcepParseException { 337 public void pcepUpdateMsgTest8() throws PcepParseException {
399 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x5c, 338 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x5c,
...@@ -415,34 +354,27 @@ public class PcepUpdateMsgTest2 { ...@@ -415,34 +354,27 @@ public class PcepUpdateMsgTest2 {
415 354
416 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); 355 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
417 PcepMessage message = null; 356 PcepMessage message = null;
418 - try { 357 +
419 message = reader.readFrom(buffer); 358 message = reader.readFrom(buffer);
420 - } catch (PcepParseException e) {
421 - e.printStackTrace();
422 - }
423 359
424 - if (message instanceof PcepUpdateMsg) { 360 + Assert.assertTrue("PcepMessage is not instance of PcepUpdateMsg", message instanceof PcepUpdateMsg);
425 ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); 361 ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
426 message.writeTo(buf); 362 message.writeTo(buf);
427 testupdateMsg = buf.array(); 363 testupdateMsg = buf.array();
428 364
429 - int iReadLen = buf.writerIndex() - 0; 365 + int readLen = buf.writerIndex() - 0;
430 - testupdateMsg = new byte[iReadLen]; 366 + testupdateMsg = new byte[readLen];
431 - buf.readBytes(testupdateMsg, 0, iReadLen); 367 + buf.readBytes(testupdateMsg, 0, readLen);
432 368
433 - if (Arrays.equals(updateMsg, testupdateMsg)) { 369 + Assert.assertArrayEquals("PcepUpdatemsg messages are not equal", updateMsg, testupdateMsg);
434 - Assert.assertArrayEquals(updateMsg, testupdateMsg);
435 - log.debug("updateMsg are equal :" + updateMsg);
436 - } else {
437 - Assert.fail("test case failed");
438 - log.debug("not equal");
439 - }
440 - } else {
441 - Assert.fail("test case failed");
442 - log.debug("not equal");
443 - }
444 } 370 }
445 371
372 + /**
373 + * This test case is for SRP object, LSP object(StatefulRsvpErrorSpecTlv), ERO object,LSPA
374 + * bandwidth object in PcepUpdate message.
375 + *
376 + * @throws PcepParseException while parsing PCEP message
377 + */
446 @Test 378 @Test
447 public void pcepUpdateMsgTest9() throws PcepParseException { 379 public void pcepUpdateMsgTest9() throws PcepParseException {
448 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x58, 380 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x58,
...@@ -463,34 +395,27 @@ public class PcepUpdateMsgTest2 { ...@@ -463,34 +395,27 @@ public class PcepUpdateMsgTest2 {
463 395
464 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); 396 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
465 PcepMessage message = null; 397 PcepMessage message = null;
466 - try { 398 +
467 message = reader.readFrom(buffer); 399 message = reader.readFrom(buffer);
468 - } catch (PcepParseException e) {
469 - e.printStackTrace();
470 - }
471 400
472 - if (message instanceof PcepUpdateMsg) { 401 + Assert.assertTrue("PcepMessage is not instance of PcepUpdateMsg", message instanceof PcepUpdateMsg);
473 ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); 402 ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
474 message.writeTo(buf); 403 message.writeTo(buf);
475 testupdateMsg = buf.array(); 404 testupdateMsg = buf.array();
476 405
477 - int iReadLen = buf.writerIndex() - 0; 406 + int readLen = buf.writerIndex() - 0;
478 - testupdateMsg = new byte[iReadLen]; 407 + testupdateMsg = new byte[readLen];
479 - buf.readBytes(testupdateMsg, 0, iReadLen); 408 + buf.readBytes(testupdateMsg, 0, readLen);
480 409
481 - if (Arrays.equals(updateMsg, testupdateMsg)) { 410 + Assert.assertArrayEquals("PcepUpdatemsg messages are not equal", updateMsg, testupdateMsg);
482 - Assert.assertArrayEquals(updateMsg, testupdateMsg);
483 - log.debug("updateMsg are equal :" + updateMsg);
484 - } else {
485 - Assert.fail("test case failed");
486 - log.debug("not equal");
487 - }
488 - } else {
489 - Assert.fail("test case failed");
490 - log.debug("not equal");
491 - }
492 } 411 }
493 412
413 + /**
414 + * This test case is for SRP object, LSP object(StatefulRsvpErrorSpecTlv), ERO object,LSPA
415 + * bandwidth object in PcepUpdate message.
416 + *
417 + * @throws PcepParseException while parsing PCEP message
418 + */
494 @Test 419 @Test
495 public void pcepUpdateMsgTest10() throws PcepParseException { 420 public void pcepUpdateMsgTest10() throws PcepParseException {
496 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x50, 421 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x50,
...@@ -510,34 +435,27 @@ public class PcepUpdateMsgTest2 { ...@@ -510,34 +435,27 @@ public class PcepUpdateMsgTest2 {
510 435
511 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); 436 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
512 PcepMessage message = null; 437 PcepMessage message = null;
513 - try { 438 +
514 message = reader.readFrom(buffer); 439 message = reader.readFrom(buffer);
515 - } catch (PcepParseException e) {
516 - e.printStackTrace();
517 - }
518 440
519 - if (message instanceof PcepUpdateMsg) { 441 + Assert.assertTrue("PcepMessage is not instance of PcepUpdateMsg", message instanceof PcepUpdateMsg);
520 ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); 442 ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
521 message.writeTo(buf); 443 message.writeTo(buf);
522 testupdateMsg = buf.array(); 444 testupdateMsg = buf.array();
523 445
524 - int iReadLen = buf.writerIndex() - 0; 446 + int readLen = buf.writerIndex() - 0;
525 - testupdateMsg = new byte[iReadLen]; 447 + testupdateMsg = new byte[readLen];
526 - buf.readBytes(testupdateMsg, 0, iReadLen); 448 + buf.readBytes(testupdateMsg, 0, readLen);
527 449
528 - if (Arrays.equals(updateMsg, testupdateMsg)) { 450 + Assert.assertArrayEquals("PcepUpdatemsg messages are not equal", updateMsg, testupdateMsg);
529 - Assert.assertArrayEquals(updateMsg, testupdateMsg);
530 - log.debug("updateMsg are equal :" + updateMsg);
531 - } else {
532 - Assert.fail("test case failed");
533 - log.debug("not equal");
534 - }
535 - } else {
536 - Assert.fail("test case failed");
537 - log.debug("not equal");
538 - }
539 } 451 }
540 452
453 + /**
454 + * This test case is for SRP object, LSP object(StatefulLspDbVerTlv), ERO object,LSPA
455 + * bandwidth object in PcepUpdate message.
456 + *
457 + * @throws PcepParseException while parsing PCEP message
458 + */
541 @Test 459 @Test
542 public void pcepUpdateMsgTest11() throws PcepParseException { 460 public void pcepUpdateMsgTest11() throws PcepParseException {
543 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x54, 461 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x54,
...@@ -556,36 +474,27 @@ public class PcepUpdateMsgTest2 { ...@@ -556,36 +474,27 @@ public class PcepUpdateMsgTest2 {
556 ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); 474 ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
557 buffer.writeBytes(updateMsg); 475 buffer.writeBytes(updateMsg);
558 476
559 - PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); 477 + PcepFactories.getGenericReader();
560 PcepMessage message = null; 478 PcepMessage message = null;
561 - try {
562 - message = reader.readFrom(buffer);
563 - } catch (PcepParseException e) {
564 - e.printStackTrace();
565 - }
566 479
567 - if (message instanceof PcepUpdateMsg) { 480 + Assert.assertTrue("PcepMessage is not instance of PcepUpdateMsg", message instanceof PcepUpdateMsg);
568 ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); 481 ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
569 message.writeTo(buf); 482 message.writeTo(buf);
570 testupdateMsg = buf.array(); 483 testupdateMsg = buf.array();
571 484
572 - int iReadLen = buf.writerIndex() - 0; 485 + int readLen = buf.writerIndex() - 0;
573 - testupdateMsg = new byte[iReadLen]; 486 + testupdateMsg = new byte[readLen];
574 - buf.readBytes(testupdateMsg, 0, iReadLen); 487 + buf.readBytes(testupdateMsg, 0, readLen);
575 488
576 - if (Arrays.equals(updateMsg, testupdateMsg)) { 489 + Assert.assertArrayEquals("PcepUpdatemsg messages are not equal", updateMsg, testupdateMsg);
577 - Assert.assertArrayEquals(updateMsg, testupdateMsg);
578 - log.debug("updateMsg are equal :" + updateMsg);
579 - } else {
580 - Assert.fail("test case failed");
581 - log.debug("not equal");
582 - }
583 - } else {
584 - Assert.fail("test case failed");
585 - log.debug("not equal");
586 - }
587 } 490 }
588 491
492 + /**
493 + * This test case is for SRP object, LSP object(SymbolicPathNameTlv), ERO object,LSPA
494 + * bandwidth object in PcepUpdate message.
495 + *
496 + * @throws PcepParseException while parsing PCEP message
497 + */
589 @Test 498 @Test
590 public void pcepUpdateMsgTest12() throws PcepParseException { 499 public void pcepUpdateMsgTest12() throws PcepParseException {
591 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x50, 500 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x50,
...@@ -605,34 +514,27 @@ public class PcepUpdateMsgTest2 { ...@@ -605,34 +514,27 @@ public class PcepUpdateMsgTest2 {
605 514
606 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); 515 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
607 PcepMessage message = null; 516 PcepMessage message = null;
608 - try { 517 +
609 message = reader.readFrom(buffer); 518 message = reader.readFrom(buffer);
610 - } catch (PcepParseException e) {
611 - e.printStackTrace();
612 - }
613 519
614 - if (message instanceof PcepUpdateMsg) { 520 + Assert.assertTrue("PcepMessage is not instance of PcepUpdateMsg", message instanceof PcepUpdateMsg);
615 ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); 521 ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
616 message.writeTo(buf); 522 message.writeTo(buf);
617 testupdateMsg = buf.array(); 523 testupdateMsg = buf.array();
618 524
619 - int iReadLen = buf.writerIndex() - 0; 525 + int readLen = buf.writerIndex() - 0;
620 - testupdateMsg = new byte[iReadLen]; 526 + testupdateMsg = new byte[readLen];
621 - buf.readBytes(testupdateMsg, 0, iReadLen); 527 + buf.readBytes(testupdateMsg, 0, readLen);
622 528
623 - if (Arrays.equals(updateMsg, testupdateMsg)) { 529 + Assert.assertArrayEquals("PcepUpdatemsg messages are not equal", updateMsg, testupdateMsg);
624 - Assert.assertArrayEquals(updateMsg, testupdateMsg);
625 - log.debug("updateMsg are equal :" + updateMsg);
626 - } else {
627 - Assert.fail("test case failed");
628 - log.debug("not equal");
629 - }
630 - } else {
631 - Assert.fail("test case failed");
632 - log.debug("not equal");
633 - }
634 } 530 }
635 531
532 + /**
533 + * This test case is for SRP object(SymbolicPathNameTlv), LSP object(SymbolicPathNameTlv), ERO object,LSPA
534 + * bandwidth object in PcepUpdate message.
535 + *
536 + * @throws PcepParseException while parsing PCEP message
537 + */
636 @Test 538 @Test
637 public void pcepUpdateMsgTest13() throws PcepParseException { 539 public void pcepUpdateMsgTest13() throws PcepParseException {
638 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x58, 540 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x58,
...@@ -653,34 +555,27 @@ public class PcepUpdateMsgTest2 { ...@@ -653,34 +555,27 @@ public class PcepUpdateMsgTest2 {
653 555
654 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); 556 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
655 PcepMessage message = null; 557 PcepMessage message = null;
656 - try { 558 +
657 message = reader.readFrom(buffer); 559 message = reader.readFrom(buffer);
658 - } catch (PcepParseException e) {
659 - e.printStackTrace();
660 - }
661 560
662 - if (message instanceof PcepUpdateMsg) { 561 + Assert.assertTrue("PcepMessage is not instance of PcepUpdateMsg", message instanceof PcepUpdateMsg);
663 ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); 562 ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
664 message.writeTo(buf); 563 message.writeTo(buf);
665 testupdateMsg = buf.array(); 564 testupdateMsg = buf.array();
666 565
667 - int iReadLen = buf.writerIndex() - 0; 566 + int readLen = buf.writerIndex() - 0;
668 - testupdateMsg = new byte[iReadLen]; 567 + testupdateMsg = new byte[readLen];
669 - buf.readBytes(testupdateMsg, 0, iReadLen); 568 + buf.readBytes(testupdateMsg, 0, readLen);
670 569
671 - if (Arrays.equals(updateMsg, testupdateMsg)) { 570 + Assert.assertArrayEquals("PcepUpdatemsg messages are not equal", updateMsg, testupdateMsg);
672 - Assert.assertArrayEquals(updateMsg, testupdateMsg);
673 - log.debug("updateMsg are equal :" + updateMsg);
674 - } else {
675 - Assert.fail("test case failed");
676 - log.debug("not equal");
677 - }
678 - } else {
679 - Assert.fail("test case failed");
680 - log.debug("not equal");
681 - }
682 } 571 }
683 572
573 + /**
574 + * This test case is for SRP object, LSP object(StatefulIPv4LspIdentidiersTlv), ERO object,LSPA
575 + * metric object in PcepUpdate message.
576 + *
577 + * @throws PcepParseException while parsing PCEP message
578 + */
684 @Test 579 @Test
685 public void pcepUpdateMsgTest14() throws PcepParseException { 580 public void pcepUpdateMsgTest14() throws PcepParseException {
686 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x60, 581 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x60,
...@@ -702,34 +597,27 @@ public class PcepUpdateMsgTest2 { ...@@ -702,34 +597,27 @@ public class PcepUpdateMsgTest2 {
702 597
703 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); 598 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
704 PcepMessage message = null; 599 PcepMessage message = null;
705 - try { 600 +
706 message = reader.readFrom(buffer); 601 message = reader.readFrom(buffer);
707 - } catch (PcepParseException e) {
708 - e.printStackTrace();
709 - }
710 602
711 - if (message instanceof PcepUpdateMsg) { 603 + Assert.assertTrue("PcepMessage is not instance of PcepUpdateMsg", message instanceof PcepUpdateMsg);
712 ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); 604 ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
713 message.writeTo(buf); 605 message.writeTo(buf);
714 testupdateMsg = buf.array(); 606 testupdateMsg = buf.array();
715 607
716 - int iReadLen = buf.writerIndex() - 0; 608 + int readLen = buf.writerIndex() - 0;
717 - testupdateMsg = new byte[iReadLen]; 609 + testupdateMsg = new byte[readLen];
718 - buf.readBytes(testupdateMsg, 0, iReadLen); 610 + buf.readBytes(testupdateMsg, 0, readLen);
719 611
720 - if (Arrays.equals(updateMsg, testupdateMsg)) { 612 + Assert.assertArrayEquals("PcepUpdatemsg messages are not equal", updateMsg, testupdateMsg);
721 - Assert.assertArrayEquals(updateMsg, testupdateMsg);
722 - log.debug("updateMsg are equal :" + updateMsg);
723 - } else {
724 - Assert.fail("test case failed");
725 - log.debug("not equal");
726 - }
727 - } else {
728 - Assert.fail("test case failed");
729 - log.debug("not equal");
730 - }
731 } 613 }
732 614
615 + /**
616 + * This test case is for SRP object, LSP object, ERO object,LSPA
617 + * metric object in PcepUpdate message.
618 + *
619 + * @throws PcepParseException while parsing PCEP message
620 + */
733 @Test 621 @Test
734 public void pcepUpdateMsgTest15() throws PcepParseException { 622 public void pcepUpdateMsgTest15() throws PcepParseException {
735 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x4c, 623 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x4c,
...@@ -748,34 +636,27 @@ public class PcepUpdateMsgTest2 { ...@@ -748,34 +636,27 @@ public class PcepUpdateMsgTest2 {
748 636
749 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); 637 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
750 PcepMessage message = null; 638 PcepMessage message = null;
751 - try { 639 +
752 message = reader.readFrom(buffer); 640 message = reader.readFrom(buffer);
753 - } catch (PcepParseException e) {
754 - e.printStackTrace();
755 - }
756 641
757 - if (message instanceof PcepUpdateMsg) { 642 + Assert.assertTrue("PcepMessage is not instance of PcepUpdateMsg", message instanceof PcepUpdateMsg);
758 ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); 643 ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
759 message.writeTo(buf); 644 message.writeTo(buf);
760 testupdateMsg = buf.array(); 645 testupdateMsg = buf.array();
761 646
762 - int iReadLen = buf.writerIndex() - 0; 647 + int readLen = buf.writerIndex() - 0;
763 - testupdateMsg = new byte[iReadLen]; 648 + testupdateMsg = new byte[readLen];
764 - buf.readBytes(testupdateMsg, 0, iReadLen); 649 + buf.readBytes(testupdateMsg, 0, readLen);
765 650
766 - if (Arrays.equals(updateMsg, testupdateMsg)) { 651 + Assert.assertArrayEquals("PcepUpdatemsg messages are not equal", updateMsg, testupdateMsg);
767 - Assert.assertArrayEquals(updateMsg, testupdateMsg);
768 - log.debug("updateMsg are equal :" + updateMsg);
769 - } else {
770 - Assert.fail("test case failed");
771 - log.debug("not equal");
772 - }
773 - } else {
774 - Assert.fail("test case failed");
775 - log.debug("not equal");
776 - }
777 } 652 }
778 653
654 + /**
655 + * This test case is for SRP object, LSP object(StatefulLspErrorCodeTlv), ERO object,LSPA
656 + * metric object in PcepUpdate message.
657 + *
658 + * @throws PcepParseException while parsing PCEP message
659 + */
779 @Test 660 @Test
780 public void pcepUpdateMsgTest16() throws PcepParseException { 661 public void pcepUpdateMsgTest16() throws PcepParseException {
781 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x54, 662 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x54,
...@@ -795,34 +676,27 @@ public class PcepUpdateMsgTest2 { ...@@ -795,34 +676,27 @@ public class PcepUpdateMsgTest2 {
795 676
796 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); 677 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
797 PcepMessage message = null; 678 PcepMessage message = null;
798 - try { 679 +
799 message = reader.readFrom(buffer); 680 message = reader.readFrom(buffer);
800 - } catch (PcepParseException e) {
801 - e.printStackTrace();
802 - }
803 681
804 - if (message instanceof PcepUpdateMsg) { 682 + Assert.assertTrue("PcepMessage is not instance of PcepUpdateMsg", message instanceof PcepUpdateMsg);
805 ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); 683 ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
806 message.writeTo(buf); 684 message.writeTo(buf);
807 testupdateMsg = buf.array(); 685 testupdateMsg = buf.array();
808 686
809 - int iReadLen = buf.writerIndex() - 0; 687 + int readLen = buf.writerIndex() - 0;
810 - testupdateMsg = new byte[iReadLen]; 688 + testupdateMsg = new byte[readLen];
811 - buf.readBytes(testupdateMsg, 0, iReadLen); 689 + buf.readBytes(testupdateMsg, 0, readLen);
812 690
813 - if (Arrays.equals(updateMsg, testupdateMsg)) { 691 + Assert.assertArrayEquals("PcepUpdatemsg messages are not equal", updateMsg, testupdateMsg);
814 - Assert.assertArrayEquals(updateMsg, testupdateMsg);
815 - log.debug("updateMsg are equal :" + updateMsg);
816 - } else {
817 - Assert.fail("test case failed");
818 - log.debug("not equal");
819 - }
820 - } else {
821 - Assert.fail("test case failed");
822 - log.debug("not equal");
823 - }
824 } 692 }
825 693
694 + /**
695 + * This test case is for SRP object, LSP object(StatefulLspDbVerTlv), ERO object,LSPA
696 + * metric object in PcepUpdate message.
697 + *
698 + * @throws PcepParseException while parsing PCEP message
699 + */
826 @Test 700 @Test
827 public void pcepUpdateMsgTest17() throws PcepParseException { 701 public void pcepUpdateMsgTest17() throws PcepParseException {
828 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x58, 702 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x58,
...@@ -843,34 +717,27 @@ public class PcepUpdateMsgTest2 { ...@@ -843,34 +717,27 @@ public class PcepUpdateMsgTest2 {
843 717
844 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); 718 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
845 PcepMessage message = null; 719 PcepMessage message = null;
846 - try { 720 +
847 message = reader.readFrom(buffer); 721 message = reader.readFrom(buffer);
848 - } catch (PcepParseException e) {
849 - e.printStackTrace();
850 - }
851 722
852 - if (message instanceof PcepUpdateMsg) { 723 + Assert.assertTrue("PcepMessage is not instance of PcepUpdateMsg", message instanceof PcepUpdateMsg);
853 ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); 724 ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
854 message.writeTo(buf); 725 message.writeTo(buf);
855 testupdateMsg = buf.array(); 726 testupdateMsg = buf.array();
856 727
857 - int iReadLen = buf.writerIndex() - 0; 728 + int readLen = buf.writerIndex() - 0;
858 - testupdateMsg = new byte[iReadLen]; 729 + testupdateMsg = new byte[readLen];
859 - buf.readBytes(testupdateMsg, 0, iReadLen); 730 + buf.readBytes(testupdateMsg, 0, readLen);
860 731
861 - if (Arrays.equals(updateMsg, testupdateMsg)) { 732 + Assert.assertArrayEquals("PcepUpdatemsg messages are not equal", updateMsg, testupdateMsg);
862 - Assert.assertArrayEquals(updateMsg, testupdateMsg);
863 - log.debug("updateMsg are equal :" + updateMsg);
864 - } else {
865 - Assert.fail("test case failed");
866 - log.debug("not equal");
867 - }
868 - } else {
869 - Assert.fail("test case failed");
870 - log.debug("not equal");
871 - }
872 } 733 }
873 734
735 + /**
736 + * This test case is for SRP object, LSP object(SymbolicPathNameTlv), ERO object,LSPA
737 + * metric object in PcepUpdate message.
738 + *
739 + * @throws PcepParseException while parsing PCEP message
740 + */
874 @Test 741 @Test
875 public void pcepUpdateMsgTest18() throws PcepParseException { 742 public void pcepUpdateMsgTest18() throws PcepParseException {
876 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x54, 743 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x54,
...@@ -890,34 +757,27 @@ public class PcepUpdateMsgTest2 { ...@@ -890,34 +757,27 @@ public class PcepUpdateMsgTest2 {
890 757
891 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); 758 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
892 PcepMessage message = null; 759 PcepMessage message = null;
893 - try { 760 +
894 message = reader.readFrom(buffer); 761 message = reader.readFrom(buffer);
895 - } catch (PcepParseException e) {
896 - e.printStackTrace();
897 - }
898 762
899 - if (message instanceof PcepUpdateMsg) { 763 + Assert.assertTrue("PcepMessage is not instance of PcepUpdateMsg", message instanceof PcepUpdateMsg);
900 ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); 764 ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
901 message.writeTo(buf); 765 message.writeTo(buf);
902 testupdateMsg = buf.array(); 766 testupdateMsg = buf.array();
903 767
904 - int iReadLen = buf.writerIndex() - 0; 768 + int readLen = buf.writerIndex() - 0;
905 - testupdateMsg = new byte[iReadLen]; 769 + testupdateMsg = new byte[readLen];
906 - buf.readBytes(testupdateMsg, 0, iReadLen); 770 + buf.readBytes(testupdateMsg, 0, readLen);
907 771
908 - if (Arrays.equals(updateMsg, testupdateMsg)) { 772 + Assert.assertArrayEquals("PcepUpdatemsg messages are not equal", updateMsg, testupdateMsg);
909 - Assert.assertArrayEquals(updateMsg, testupdateMsg);
910 - log.debug("updateMsg are equal :" + updateMsg);
911 - } else {
912 - Assert.fail("test case failed");
913 - log.debug("not equal");
914 - }
915 - } else {
916 - Assert.fail("test case failed");
917 - log.debug("not equal");
918 - }
919 } 773 }
920 774
775 + /**
776 + * This test case is for SRP object(SymbolicPathNameTlv), LSP object(SymbolicPathNameTlv), ERO object,
777 + * metric object in PcepUpdate message.
778 + *
779 + * @throws PcepParseException while parsing PCEP message
780 + */
921 @Test 781 @Test
922 public void pcepUpdateMsgTest19() throws PcepParseException { 782 public void pcepUpdateMsgTest19() throws PcepParseException {
923 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x5c, 783 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x5c,
...@@ -938,34 +798,27 @@ public class PcepUpdateMsgTest2 { ...@@ -938,34 +798,27 @@ public class PcepUpdateMsgTest2 {
938 798
939 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); 799 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
940 PcepMessage message = null; 800 PcepMessage message = null;
941 - try { 801 +
942 message = reader.readFrom(buffer); 802 message = reader.readFrom(buffer);
943 - } catch (PcepParseException e) {
944 - e.printStackTrace();
945 - }
946 803
947 - if (message instanceof PcepUpdateMsg) { 804 + Assert.assertTrue("PcepMessage is not instance of PcepUpdateMsg", message instanceof PcepUpdateMsg);
948 ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); 805 ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
949 message.writeTo(buf); 806 message.writeTo(buf);
950 testupdateMsg = buf.array(); 807 testupdateMsg = buf.array();
951 808
952 - int iReadLen = buf.writerIndex() - 0; 809 + int readLen = buf.writerIndex() - 0;
953 - testupdateMsg = new byte[iReadLen]; 810 + testupdateMsg = new byte[readLen];
954 - buf.readBytes(testupdateMsg, 0, iReadLen); 811 + buf.readBytes(testupdateMsg, 0, readLen);
955 812
956 - if (Arrays.equals(updateMsg, testupdateMsg)) { 813 + Assert.assertArrayEquals("PcepUpdatemsg messages are not equal", updateMsg, testupdateMsg);
957 - Assert.assertArrayEquals(updateMsg, testupdateMsg);
958 - log.debug("updateMsg are equal :" + updateMsg);
959 - } else {
960 - Assert.fail("test case failed");
961 - log.debug("not equal");
962 - }
963 - } else {
964 - Assert.fail("test case failed");
965 - log.debug("not equal");
966 - }
967 } 814 }
968 815
816 + /**
817 + * This test case is for SRP object, LSP object(StatefulIPv4LspIdentidiersTlv), ERO object,
818 + * Bandwidth , metric object in PcepUpdate message.
819 + *
820 + * @throws PcepParseException while parsing PCEP message
821 + */
969 @Test 822 @Test
970 public void pcepUpdateMsgTest20() throws PcepParseException { 823 public void pcepUpdateMsgTest20() throws PcepParseException {
971 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x54, 824 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x54,
...@@ -986,34 +839,27 @@ public class PcepUpdateMsgTest2 { ...@@ -986,34 +839,27 @@ public class PcepUpdateMsgTest2 {
986 839
987 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); 840 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
988 PcepMessage message = null; 841 PcepMessage message = null;
989 - try { 842 +
990 message = reader.readFrom(buffer); 843 message = reader.readFrom(buffer);
991 - } catch (PcepParseException e) {
992 - e.printStackTrace();
993 - }
994 844
995 - if (message instanceof PcepUpdateMsg) { 845 + Assert.assertTrue("PcepMessage is not instance of PcepUpdateMsg", message instanceof PcepUpdateMsg);
996 ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); 846 ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
997 message.writeTo(buf); 847 message.writeTo(buf);
998 testupdateMsg = buf.array(); 848 testupdateMsg = buf.array();
999 849
1000 - int iReadLen = buf.writerIndex() - 0; 850 + int readLen = buf.writerIndex() - 0;
1001 - testupdateMsg = new byte[iReadLen]; 851 + testupdateMsg = new byte[readLen];
1002 - buf.readBytes(testupdateMsg, 0, iReadLen); 852 + buf.readBytes(testupdateMsg, 0, readLen);
1003 853
1004 - if (Arrays.equals(updateMsg, testupdateMsg)) { 854 + Assert.assertArrayEquals("PcepUpdatemsg messages are not equal", updateMsg, testupdateMsg);
1005 - Assert.assertArrayEquals(updateMsg, testupdateMsg);
1006 - log.debug("updateMsg are equal :" + updateMsg);
1007 - } else {
1008 - Assert.fail("test case failed");
1009 - log.debug("not equal");
1010 - }
1011 - } else {
1012 - Assert.fail("test case failed");
1013 - log.debug("not equal");
1014 - }
1015 } 855 }
1016 856
857 + /**
858 + * This test case is for SRP object, LSP object, ERO object,
859 + * Bandwidth , metric object in PcepUpdate message.
860 + *
861 + * @throws PcepParseException while parsing PCEP message
862 + */
1017 @Test 863 @Test
1018 public void pcepUpdateMsgTest21() throws PcepParseException { 864 public void pcepUpdateMsgTest21() throws PcepParseException {
1019 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x40, 865 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x40,
...@@ -1031,34 +877,27 @@ public class PcepUpdateMsgTest2 { ...@@ -1031,34 +877,27 @@ public class PcepUpdateMsgTest2 {
1031 877
1032 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); 878 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
1033 PcepMessage message = null; 879 PcepMessage message = null;
1034 - try { 880 +
1035 message = reader.readFrom(buffer); 881 message = reader.readFrom(buffer);
1036 - } catch (PcepParseException e) {
1037 - e.printStackTrace();
1038 - }
1039 882
1040 - if (message instanceof PcepUpdateMsg) { 883 + Assert.assertTrue("PcepMessage is not instance of PcepUpdateMsg", message instanceof PcepUpdateMsg);
1041 ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); 884 ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
1042 message.writeTo(buf); 885 message.writeTo(buf);
1043 testupdateMsg = buf.array(); 886 testupdateMsg = buf.array();
1044 887
1045 - int iReadLen = buf.writerIndex() - 0; 888 + int readLen = buf.writerIndex() - 0;
1046 - testupdateMsg = new byte[iReadLen]; 889 + testupdateMsg = new byte[readLen];
1047 - buf.readBytes(testupdateMsg, 0, iReadLen); 890 + buf.readBytes(testupdateMsg, 0, readLen);
1048 891
1049 - if (Arrays.equals(updateMsg, testupdateMsg)) { 892 + Assert.assertArrayEquals("PcepUpdatemsg messages are not equal", updateMsg, testupdateMsg);
1050 - Assert.assertArrayEquals(updateMsg, testupdateMsg);
1051 - log.debug("updateMsg are equal :" + updateMsg);
1052 - } else {
1053 - Assert.fail("test case failed");
1054 - log.debug("not equal");
1055 - }
1056 - } else {
1057 - Assert.fail("test case failed");
1058 - log.debug("not equal");
1059 - }
1060 } 893 }
1061 894
895 + /**
896 + * This test case is for SRP object, LSP object(StatefulLspErrorCodeTlv), ERO object,
897 + * Bandwidth , metric object in PcepUpdate message.
898 + *
899 + * @throws PcepParseException while parsing PCEP message
900 + */
1062 @Test 901 @Test
1063 public void pcepUpdateMsgTest22() throws PcepParseException { 902 public void pcepUpdateMsgTest22() throws PcepParseException {
1064 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x48, 903 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x48,
...@@ -1077,34 +916,27 @@ public class PcepUpdateMsgTest2 { ...@@ -1077,34 +916,27 @@ public class PcepUpdateMsgTest2 {
1077 916
1078 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); 917 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
1079 PcepMessage message = null; 918 PcepMessage message = null;
1080 - try { 919 +
1081 message = reader.readFrom(buffer); 920 message = reader.readFrom(buffer);
1082 - } catch (PcepParseException e) {
1083 - e.printStackTrace();
1084 - }
1085 921
1086 - if (message instanceof PcepUpdateMsg) { 922 + Assert.assertTrue("PcepMessage is not instance of PcepUpdateMsg", message instanceof PcepUpdateMsg);
1087 ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); 923 ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
1088 message.writeTo(buf); 924 message.writeTo(buf);
1089 testupdateMsg = buf.array(); 925 testupdateMsg = buf.array();
1090 926
1091 - int iReadLen = buf.writerIndex() - 0; 927 + int readLen = buf.writerIndex() - 0;
1092 - testupdateMsg = new byte[iReadLen]; 928 + testupdateMsg = new byte[readLen];
1093 - buf.readBytes(testupdateMsg, 0, iReadLen); 929 + buf.readBytes(testupdateMsg, 0, readLen);
1094 930
1095 - if (Arrays.equals(updateMsg, testupdateMsg)) { 931 + Assert.assertArrayEquals("PcepUpdatemsg messages are not equal", updateMsg, testupdateMsg);
1096 - Assert.assertArrayEquals(updateMsg, testupdateMsg);
1097 - log.debug("updateMsg are equal :" + updateMsg);
1098 - } else {
1099 - Assert.fail("test case failed");
1100 - log.debug("not equal");
1101 - }
1102 - } else {
1103 - Assert.fail("test case failed");
1104 - log.debug("not equal");
1105 - }
1106 } 932 }
1107 933
934 + /**
935 + * This test case is for SRP object, LSP object(StatefulLspDbVerTlv), ERO object,
936 + * Bandwidth , metric object in PcepUpdate message.
937 + *
938 + * @throws PcepParseException while parsing PCEP message
939 + */
1108 @Test 940 @Test
1109 public void pcepUpdateMsgTest23() throws PcepParseException { 941 public void pcepUpdateMsgTest23() throws PcepParseException {
1110 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x4c, 942 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x4c,
...@@ -1124,34 +956,27 @@ public class PcepUpdateMsgTest2 { ...@@ -1124,34 +956,27 @@ public class PcepUpdateMsgTest2 {
1124 956
1125 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); 957 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
1126 PcepMessage message = null; 958 PcepMessage message = null;
1127 - try { 959 +
1128 message = reader.readFrom(buffer); 960 message = reader.readFrom(buffer);
1129 - } catch (PcepParseException e) {
1130 - e.printStackTrace();
1131 - }
1132 961
1133 - if (message instanceof PcepUpdateMsg) { 962 + Assert.assertTrue("PcepMessage is not instance of PcepUpdateMsg", message instanceof PcepUpdateMsg);
1134 ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); 963 ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
1135 message.writeTo(buf); 964 message.writeTo(buf);
1136 testupdateMsg = buf.array(); 965 testupdateMsg = buf.array();
1137 966
1138 - int iReadLen = buf.writerIndex() - 0; 967 + int readLen = buf.writerIndex() - 0;
1139 - testupdateMsg = new byte[iReadLen]; 968 + testupdateMsg = new byte[readLen];
1140 - buf.readBytes(testupdateMsg, 0, iReadLen); 969 + buf.readBytes(testupdateMsg, 0, readLen);
1141 970
1142 - if (Arrays.equals(updateMsg, testupdateMsg)) { 971 + Assert.assertArrayEquals("PcepUpdatemsg messages are not equal", updateMsg, testupdateMsg);
1143 - Assert.assertArrayEquals(updateMsg, testupdateMsg);
1144 - log.debug("updateMsg are equal :" + updateMsg);
1145 - } else {
1146 - Assert.fail("test case failed");
1147 - log.debug("not equal");
1148 - }
1149 - } else {
1150 - Assert.fail("test case failed");
1151 - log.debug("not equal");
1152 - }
1153 } 972 }
1154 973
974 + /**
975 + * This test case is for SRP object, LSP object(SymbolicPathNameTlv), ERO object,
976 + * Bandwidth , metric object in PcepUpdate message.
977 + *
978 + * @throws PcepParseException while parsing PCEP message
979 + */
1155 @Test 980 @Test
1156 public void pcepUpdateMsgTest24() throws PcepParseException { 981 public void pcepUpdateMsgTest24() throws PcepParseException {
1157 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x48, 982 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x48,
...@@ -1170,34 +995,27 @@ public class PcepUpdateMsgTest2 { ...@@ -1170,34 +995,27 @@ public class PcepUpdateMsgTest2 {
1170 995
1171 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); 996 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
1172 PcepMessage message = null; 997 PcepMessage message = null;
1173 - try { 998 +
1174 message = reader.readFrom(buffer); 999 message = reader.readFrom(buffer);
1175 - } catch (PcepParseException e) {
1176 - e.printStackTrace();
1177 - }
1178 1000
1179 - if (message instanceof PcepUpdateMsg) { 1001 + Assert.assertTrue("PcepMessage is not instance of PcepUpdateMsg", message instanceof PcepUpdateMsg);
1180 ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); 1002 ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
1181 message.writeTo(buf); 1003 message.writeTo(buf);
1182 testupdateMsg = buf.array(); 1004 testupdateMsg = buf.array();
1183 1005
1184 - int iReadLen = buf.writerIndex() - 0; 1006 + int readLen = buf.writerIndex() - 0;
1185 - testupdateMsg = new byte[iReadLen]; 1007 + testupdateMsg = new byte[readLen];
1186 - buf.readBytes(testupdateMsg, 0, iReadLen); 1008 + buf.readBytes(testupdateMsg, 0, readLen);
1187 1009
1188 - if (Arrays.equals(updateMsg, testupdateMsg)) { 1010 + Assert.assertArrayEquals("PcepUpdatemsg messages are not equal", updateMsg, testupdateMsg);
1189 - Assert.assertArrayEquals(updateMsg, testupdateMsg);
1190 - log.debug("updateMsg are equal :" + updateMsg);
1191 - } else {
1192 - Assert.fail("test case failed");
1193 - log.debug("not equal");
1194 - }
1195 - } else {
1196 - Assert.fail("test case failed");
1197 - log.debug("not equal");
1198 - }
1199 } 1011 }
1200 1012
1013 + /**
1014 + * This test case is for SRP object(SymbolicPathNameTlv), LSP object(SymbolicPathNameTlv), ERO object,
1015 + * Bandwidth , metric object in PcepUpdate message.
1016 + *
1017 + * @throws PcepParseException while parsing PCEP message
1018 + */
1201 @Test 1019 @Test
1202 public void pcepUpdateMsgTest25() throws PcepParseException { 1020 public void pcepUpdateMsgTest25() throws PcepParseException {
1203 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x50, 1021 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x50,
...@@ -1217,34 +1035,27 @@ public class PcepUpdateMsgTest2 { ...@@ -1217,34 +1035,27 @@ public class PcepUpdateMsgTest2 {
1217 1035
1218 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); 1036 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
1219 PcepMessage message = null; 1037 PcepMessage message = null;
1220 - try { 1038 +
1221 message = reader.readFrom(buffer); 1039 message = reader.readFrom(buffer);
1222 - } catch (PcepParseException e) {
1223 - e.printStackTrace();
1224 - }
1225 1040
1226 - if (message instanceof PcepUpdateMsg) { 1041 + Assert.assertTrue("PcepMessage is not instance of PcepUpdateMsg", message instanceof PcepUpdateMsg);
1227 ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); 1042 ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
1228 message.writeTo(buf); 1043 message.writeTo(buf);
1229 testupdateMsg = buf.array(); 1044 testupdateMsg = buf.array();
1230 1045
1231 - int iReadLen = buf.writerIndex() - 0; 1046 + int readLen = buf.writerIndex() - 0;
1232 - testupdateMsg = new byte[iReadLen]; 1047 + testupdateMsg = new byte[readLen];
1233 - buf.readBytes(testupdateMsg, 0, iReadLen); 1048 + buf.readBytes(testupdateMsg, 0, readLen);
1234 1049
1235 - if (Arrays.equals(updateMsg, testupdateMsg)) { 1050 + Assert.assertArrayEquals("PcepUpdatemsg messages are not equal", updateMsg, testupdateMsg);
1236 - Assert.assertArrayEquals(updateMsg, testupdateMsg);
1237 - log.debug("updateMsg are equal :" + updateMsg);
1238 - } else {
1239 - Assert.fail("test case failed");
1240 - log.debug("not equal");
1241 - }
1242 - } else {
1243 - Assert.fail("test case failed");
1244 - log.debug("not equal");
1245 - }
1246 } 1051 }
1247 1052
1053 + /**
1054 + * This test case is for SRP object, LSP object(StatefulIPv4LspIdentidiersTlv), ERO object,
1055 + * LSPA object in PcepUpdate message.
1056 + *
1057 + * @throws PcepParseException while parsing PCEP message
1058 + */
1248 @Test 1059 @Test
1249 public void pcepUpdateMsgTest26() throws PcepParseException { 1060 public void pcepUpdateMsgTest26() throws PcepParseException {
1250 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x54, 1061 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x54,
...@@ -1265,34 +1076,27 @@ public class PcepUpdateMsgTest2 { ...@@ -1265,34 +1076,27 @@ public class PcepUpdateMsgTest2 {
1265 1076
1266 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); 1077 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
1267 PcepMessage message = null; 1078 PcepMessage message = null;
1268 - try { 1079 +
1269 message = reader.readFrom(buffer); 1080 message = reader.readFrom(buffer);
1270 - } catch (PcepParseException e) {
1271 - e.printStackTrace();
1272 - }
1273 1081
1274 - if (message instanceof PcepUpdateMsg) { 1082 + Assert.assertTrue("PcepMessage is not instance of PcepUpdateMsg", message instanceof PcepUpdateMsg);
1275 ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); 1083 ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
1276 message.writeTo(buf); 1084 message.writeTo(buf);
1277 testupdateMsg = buf.array(); 1085 testupdateMsg = buf.array();
1278 1086
1279 - int iReadLen = buf.writerIndex() - 0; 1087 + int readLen = buf.writerIndex() - 0;
1280 - testupdateMsg = new byte[iReadLen]; 1088 + testupdateMsg = new byte[readLen];
1281 - buf.readBytes(testupdateMsg, 0, iReadLen); 1089 + buf.readBytes(testupdateMsg, 0, readLen);
1282 1090
1283 - if (Arrays.equals(updateMsg, testupdateMsg)) { 1091 + Assert.assertArrayEquals("PcepUpdatemsg messages are not equal", updateMsg, testupdateMsg);
1284 - Assert.assertArrayEquals(updateMsg, testupdateMsg);
1285 - log.debug("updateMsg are equal :" + updateMsg);
1286 - } else {
1287 - Assert.fail("test case failed");
1288 - log.debug("not equal");
1289 - }
1290 - } else {
1291 - Assert.fail("test case failed");
1292 - log.debug("not equal");
1293 - }
1294 } 1092 }
1295 1093
1094 + /**
1095 + * This test case is for SRP object, LSP object, ERO object,
1096 + * bandwidth object in PcepUpdate message.
1097 + *
1098 + * @throws PcepParseException while parsing PCEP message
1099 + */
1296 @Test 1100 @Test
1297 public void pcepUpdateMsgTest27() throws PcepParseException { 1101 public void pcepUpdateMsgTest27() throws PcepParseException {
1298 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x34, 1102 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x34,
...@@ -1309,34 +1113,27 @@ public class PcepUpdateMsgTest2 { ...@@ -1309,34 +1113,27 @@ public class PcepUpdateMsgTest2 {
1309 1113
1310 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); 1114 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
1311 PcepMessage message = null; 1115 PcepMessage message = null;
1312 - try { 1116 +
1313 message = reader.readFrom(buffer); 1117 message = reader.readFrom(buffer);
1314 - } catch (PcepParseException e) {
1315 - e.printStackTrace();
1316 - }
1317 1118
1318 - if (message instanceof PcepUpdateMsg) { 1119 + Assert.assertTrue("PcepMessage is not instance of PcepUpdateMsg", message instanceof PcepUpdateMsg);
1319 ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); 1120 ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
1320 message.writeTo(buf); 1121 message.writeTo(buf);
1321 testupdateMsg = buf.array(); 1122 testupdateMsg = buf.array();
1322 1123
1323 - int iReadLen = buf.writerIndex() - 0; 1124 + int readLen = buf.writerIndex() - 0;
1324 - testupdateMsg = new byte[iReadLen]; 1125 + testupdateMsg = new byte[readLen];
1325 - buf.readBytes(testupdateMsg, 0, iReadLen); 1126 + buf.readBytes(testupdateMsg, 0, readLen);
1326 1127
1327 - if (Arrays.equals(updateMsg, testupdateMsg)) { 1128 + Assert.assertArrayEquals("PcepUpdatemsg messages are not equal", updateMsg, testupdateMsg);
1328 - Assert.assertArrayEquals(updateMsg, testupdateMsg);
1329 - log.debug("updateMsg are equal :" + updateMsg);
1330 - } else {
1331 - Assert.fail("test case failed");
1332 - log.debug("not equal");
1333 - }
1334 - } else {
1335 - Assert.fail("test case failed");
1336 - log.debug("not equal");
1337 - }
1338 } 1129 }
1339 1130
1131 + /**
1132 + * This test case is for SRP object, LSP object(StatefulLspErrorCodeTlv), ERO object,
1133 + * metric object in PcepUpdate message.
1134 + *
1135 + * @throws PcepParseException while parsing PCEP message
1136 + */
1340 @Test 1137 @Test
1341 public void pcepUpdateMsgTest28() throws PcepParseException { 1138 public void pcepUpdateMsgTest28() throws PcepParseException {
1342 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x40, 1139 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x40,
...@@ -1354,34 +1151,27 @@ public class PcepUpdateMsgTest2 { ...@@ -1354,34 +1151,27 @@ public class PcepUpdateMsgTest2 {
1354 1151
1355 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); 1152 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
1356 PcepMessage message = null; 1153 PcepMessage message = null;
1357 - try { 1154 +
1358 message = reader.readFrom(buffer); 1155 message = reader.readFrom(buffer);
1359 - } catch (PcepParseException e) {
1360 - e.printStackTrace();
1361 - }
1362 1156
1363 - if (message instanceof PcepUpdateMsg) { 1157 + Assert.assertTrue("PcepMessage is not instance of PcepUpdateMsg", message instanceof PcepUpdateMsg);
1364 ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); 1158 ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
1365 message.writeTo(buf); 1159 message.writeTo(buf);
1366 testupdateMsg = buf.array(); 1160 testupdateMsg = buf.array();
1367 1161
1368 - int iReadLen = buf.writerIndex() - 0; 1162 + int readLen = buf.writerIndex() - 0;
1369 - testupdateMsg = new byte[iReadLen]; 1163 + testupdateMsg = new byte[readLen];
1370 - buf.readBytes(testupdateMsg, 0, iReadLen); 1164 + buf.readBytes(testupdateMsg, 0, readLen);
1371 1165
1372 - if (Arrays.equals(updateMsg, testupdateMsg)) { 1166 + Assert.assertArrayEquals("PcepUpdatemsg messages are not equal", updateMsg, testupdateMsg);
1373 - Assert.assertArrayEquals(updateMsg, testupdateMsg);
1374 - log.debug("updateMsg are equal :" + updateMsg);
1375 - } else {
1376 - Assert.fail("test case failed");
1377 - log.debug("not equal");
1378 - }
1379 - } else {
1380 - Assert.fail("test case failed");
1381 - log.debug("not equal");
1382 - }
1383 } 1167 }
1384 1168
1169 + /**
1170 + * This test case is for SRP object(SymbolicPathNameTlv), LSP object(StatefulLspErrorCodeTlv), ERO object,
1171 + * lspa object in PcepUpdate message.
1172 + *
1173 + * @throws PcepParseException while parsing PCEP message
1174 + */
1385 @Test 1175 @Test
1386 public void pcepUpdateMsgTest29() throws PcepParseException { 1176 public void pcepUpdateMsgTest29() throws PcepParseException {
1387 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x54, 1177 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x54,
...@@ -1402,34 +1192,27 @@ public class PcepUpdateMsgTest2 { ...@@ -1402,34 +1192,27 @@ public class PcepUpdateMsgTest2 {
1402 1192
1403 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); 1193 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
1404 PcepMessage message = null; 1194 PcepMessage message = null;
1405 - try { 1195 +
1406 message = reader.readFrom(buffer); 1196 message = reader.readFrom(buffer);
1407 - } catch (PcepParseException e) {
1408 - e.printStackTrace();
1409 - }
1410 1197
1411 - if (message instanceof PcepUpdateMsg) { 1198 + Assert.assertTrue("PcepMessage is not instance of PcepUpdateMsg", message instanceof PcepUpdateMsg);
1412 ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); 1199 ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
1413 message.writeTo(buf); 1200 message.writeTo(buf);
1414 testupdateMsg = buf.array(); 1201 testupdateMsg = buf.array();
1415 1202
1416 - int iReadLen = buf.writerIndex() - 0; 1203 + int readLen = buf.writerIndex() - 0;
1417 - testupdateMsg = new byte[iReadLen]; 1204 + testupdateMsg = new byte[readLen];
1418 - buf.readBytes(testupdateMsg, 0, iReadLen); 1205 + buf.readBytes(testupdateMsg, 0, readLen);
1419 1206
1420 - if (Arrays.equals(updateMsg, testupdateMsg)) { 1207 + Assert.assertArrayEquals("PcepUpdatemsg messages are not equal", updateMsg, testupdateMsg);
1421 - Assert.assertArrayEquals(updateMsg, testupdateMsg);
1422 - log.debug("updateMsg are equal :" + updateMsg);
1423 - } else {
1424 - Assert.fail("test case failed");
1425 - log.debug("not equal");
1426 - }
1427 - } else {
1428 - Assert.fail("test case failed");
1429 - log.debug("not equal");
1430 - }
1431 } 1208 }
1432 1209
1210 + /**
1211 + * This test case is for SRP object(SymbolicPathNameTlv), LSP object(StatefulLspErrorCodeTlv), ERO object,
1212 + * bandwidth object in PcepUpdate message.
1213 + *
1214 + * @throws PcepParseException while parsing PCEP message
1215 + */
1433 @Test 1216 @Test
1434 public void pcepUpdateMsgTest30() throws PcepParseException { 1217 public void pcepUpdateMsgTest30() throws PcepParseException {
1435 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x48, 1218 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x48,
...@@ -1449,34 +1232,27 @@ public class PcepUpdateMsgTest2 { ...@@ -1449,34 +1232,27 @@ public class PcepUpdateMsgTest2 {
1449 1232
1450 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); 1233 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
1451 PcepMessage message = null; 1234 PcepMessage message = null;
1452 - try { 1235 +
1453 message = reader.readFrom(buffer); 1236 message = reader.readFrom(buffer);
1454 - } catch (PcepParseException e) {
1455 - e.printStackTrace();
1456 - }
1457 1237
1458 - if (message instanceof PcepUpdateMsg) { 1238 + Assert.assertTrue("PcepMessage is not instance of PcepUpdateMsg", message instanceof PcepUpdateMsg);
1459 ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); 1239 ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
1460 message.writeTo(buf); 1240 message.writeTo(buf);
1461 testupdateMsg = buf.array(); 1241 testupdateMsg = buf.array();
1462 1242
1463 - int iReadLen = buf.writerIndex() - 0; 1243 + int readLen = buf.writerIndex() - 0;
1464 - testupdateMsg = new byte[iReadLen]; 1244 + testupdateMsg = new byte[readLen];
1465 - buf.readBytes(testupdateMsg, 0, iReadLen); 1245 + buf.readBytes(testupdateMsg, 0, readLen);
1466 1246
1467 - if (Arrays.equals(updateMsg, testupdateMsg)) { 1247 + Assert.assertArrayEquals("PcepUpdatemsg messages are not equal", updateMsg, testupdateMsg);
1468 - Assert.assertArrayEquals(updateMsg, testupdateMsg);
1469 - log.debug("updateMsg are equal :" + updateMsg);
1470 - } else {
1471 - Assert.fail("test case failed");
1472 - log.debug("not equal");
1473 - }
1474 - } else {
1475 - Assert.fail("test case failed");
1476 - log.debug("not equal");
1477 - }
1478 } 1248 }
1479 1249
1250 + /**
1251 + * This test case is for SRP object(SymbolicPathNameTlv), LSP object(StatefulLspErrorCodeTlv), ERO object,
1252 + * metric object in PcepUpdate message.
1253 + *
1254 + * @throws PcepParseException while parsing PCEP message
1255 + */
1480 @Test 1256 @Test
1481 public void pcepUpdateMsgTest31() throws PcepParseException { 1257 public void pcepUpdateMsgTest31() throws PcepParseException {
1482 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x4c, 1258 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x4c,
...@@ -1496,34 +1272,27 @@ public class PcepUpdateMsgTest2 { ...@@ -1496,34 +1272,27 @@ public class PcepUpdateMsgTest2 {
1496 1272
1497 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); 1273 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
1498 PcepMessage message = null; 1274 PcepMessage message = null;
1499 - try { 1275 +
1500 message = reader.readFrom(buffer); 1276 message = reader.readFrom(buffer);
1501 - } catch (PcepParseException e) {
1502 - e.printStackTrace();
1503 - }
1504 1277
1505 - if (message instanceof PcepUpdateMsg) { 1278 + Assert.assertTrue("PcepMessage is not instance of PcepUpdateMsg", message instanceof PcepUpdateMsg);
1506 ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); 1279 ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
1507 message.writeTo(buf); 1280 message.writeTo(buf);
1508 testupdateMsg = buf.array(); 1281 testupdateMsg = buf.array();
1509 1282
1510 - int iReadLen = buf.writerIndex() - 0; 1283 + int readLen = buf.writerIndex() - 0;
1511 - testupdateMsg = new byte[iReadLen]; 1284 + testupdateMsg = new byte[readLen];
1512 - buf.readBytes(testupdateMsg, 0, iReadLen); 1285 + buf.readBytes(testupdateMsg, 0, readLen);
1513 1286
1514 - if (Arrays.equals(updateMsg, testupdateMsg)) { 1287 + Assert.assertArrayEquals("PcepUpdatemsg messages are not equal", updateMsg, testupdateMsg);
1515 - Assert.assertArrayEquals(updateMsg, testupdateMsg);
1516 - log.debug("updateMsg are equal :" + updateMsg);
1517 - } else {
1518 - Assert.fail("test case failed");
1519 - log.debug("not equal");
1520 - }
1521 - } else {
1522 - Assert.fail("test case failed");
1523 - log.debug("not equal");
1524 - }
1525 } 1288 }
1526 1289
1290 + /**
1291 + * This test case is for SRP object(symbolic path tlv), LSP object(StatefulLspDbVerTlv), ERO object,
1292 + * Metric object in PcepUpdate message.
1293 + *
1294 + * @throws PcepParseException while parsing PCEP message
1295 + */
1527 @Test 1296 @Test
1528 public void pcepUpdateMsgTest32() throws PcepParseException { 1297 public void pcepUpdateMsgTest32() throws PcepParseException {
1529 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x64, 1298 byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x64,
...@@ -1545,32 +1314,19 @@ public class PcepUpdateMsgTest2 { ...@@ -1545,32 +1314,19 @@ public class PcepUpdateMsgTest2 {
1545 1314
1546 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); 1315 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
1547 PcepMessage message = null; 1316 PcepMessage message = null;
1548 - try { 1317 +
1549 message = reader.readFrom(buffer); 1318 message = reader.readFrom(buffer);
1550 - } catch (PcepParseException e) {
1551 - e.printStackTrace();
1552 - }
1553 1319
1554 - if (message instanceof PcepUpdateMsg) { 1320 + Assert.assertTrue("PcepMessage is not instance of PcepUpdateMsg", message instanceof PcepUpdateMsg);
1555 ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); 1321 ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
1556 message.writeTo(buf); 1322 message.writeTo(buf);
1557 testupdateMsg = buf.array(); 1323 testupdateMsg = buf.array();
1558 1324
1559 - int iReadLen = buf.writerIndex() - 0; 1325 + int readLen = buf.writerIndex() - 0;
1560 - testupdateMsg = new byte[iReadLen]; 1326 + testupdateMsg = new byte[readLen];
1561 - buf.readBytes(testupdateMsg, 0, iReadLen); 1327 + buf.readBytes(testupdateMsg, 0, readLen);
1562 1328
1563 - if (Arrays.equals(updateMsg, testupdateMsg)) { 1329 + Assert.assertArrayEquals("PcepUpdatemsg messages are not equal", updateMsg, testupdateMsg);
1564 - Assert.assertArrayEquals(updateMsg, testupdateMsg);
1565 - log.debug("updateMsg are equal :" + updateMsg);
1566 - } else {
1567 - Assert.fail("test case failed");
1568 - log.debug("not equal");
1569 - }
1570 - } else {
1571 - Assert.fail("test case failed");
1572 - log.debug("not equal");
1573 - }
1574 } 1330 }
1575 } 1331 }
1576 1332
......