Committed by
Gerrit Code Review
PcepUpdateMsg UT updated for adding javadoc, remove log and if check.
Change-Id: I2604ba9e9ba481e5535043fdcd8225be4acc0ee4
Showing
2 changed files
with
1248 additions
and
1852 deletions
... | @@ -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 { | ||
65 | - message = reader.readFrom(buffer); | ||
66 | - } catch (PcepParseException e) { | ||
67 | - e.printStackTrace(); | ||
68 | - } | ||
69 | - | ||
70 | - if (message instanceof PcepUpdateMsg) { | ||
71 | - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); | ||
72 | - message.writeTo(buf); | ||
73 | - testupdateMsg = buf.array(); | ||
74 | - | ||
75 | - int iReadLen = buf.writerIndex() - 0; | ||
76 | - testupdateMsg = new byte[iReadLen]; | ||
77 | - buf.readBytes(testupdateMsg, 0, iReadLen); | ||
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 | 50 | ||
51 | + message = reader.readFrom(buffer); | ||
52 | + | ||
53 | + Assert.assertTrue("PcepMessage is not instance of PcUpd", (message instanceof PcepUpdateMsg)); | ||
54 | + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); | ||
55 | + message.writeTo(buf); | ||
56 | + testupdateMsg = buf.array(); | ||
57 | + | ||
58 | + int readLen = buf.writerIndex() - 0; | ||
59 | + testupdateMsg = new byte[readLen]; | ||
60 | + buf.readBytes(testupdateMsg, 0, readLen); | ||
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 | - | ||
128 | - if (message instanceof PcepUpdateMsg) { | ||
129 | - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); | ||
130 | - message.writeTo(buf); | ||
131 | - testupdateMsg = buf.array(); | ||
132 | - | ||
133 | - int iReadLen = buf.writerIndex() - 0; | ||
134 | - testupdateMsg = new byte[iReadLen]; | ||
135 | - buf.readBytes(testupdateMsg, 0, iReadLen); | ||
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 | 97 | ||
149 | - } | 98 | + message = reader.readFrom(buffer); |
99 | + Assert.assertTrue("PcepMessage is not instance of PcUpd", (message instanceof PcepUpdateMsg)); | ||
100 | + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); | ||
101 | + message.writeTo(buf); | ||
102 | + testupdateMsg = buf.array(); | ||
150 | 103 | ||
104 | + int readLen = buf.writerIndex() - 0; | ||
105 | + testupdateMsg = new byte[readLen]; | ||
106 | + buf.readBytes(testupdateMsg, 0, readLen); | ||
151 | 107 | ||
108 | + Assert.assertArrayEquals("PcUpd messages are not equal", updateMsg, testupdateMsg); | ||
109 | + } | ||
110 | + | ||
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 { | ||
173 | - message = reader.readFrom(buffer); | ||
174 | - } catch (PcepParseException e) { | ||
175 | - e.printStackTrace(); | ||
176 | - } | ||
177 | - | ||
178 | - if (message instanceof PcepUpdateMsg) { | ||
179 | - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); | ||
180 | - message.writeTo(buf); | ||
181 | - testupdateMsg = buf.array(); | ||
182 | - | ||
183 | - int iReadLen = buf.writerIndex() - 0; | ||
184 | - testupdateMsg = new byte[iReadLen]; | ||
185 | - buf.readBytes(testupdateMsg, 0, iReadLen); | ||
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 | 135 | ||
136 | + message = reader.readFrom(buffer); | ||
137 | + | ||
138 | + Assert.assertTrue("PcepMessage is not instance of PcUpd", (message instanceof PcepUpdateMsg)); | ||
139 | + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); | ||
140 | + message.writeTo(buf); | ||
141 | + testupdateMsg = buf.array(); | ||
142 | + | ||
143 | + int readLen = buf.writerIndex() - 0; | ||
144 | + testupdateMsg = new byte[readLen]; | ||
145 | + buf.readBytes(testupdateMsg, 0, readLen); | ||
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 { | ||
222 | - message = reader.readFrom(buffer); | ||
223 | - } catch (PcepParseException e) { | ||
224 | - e.printStackTrace(); | ||
225 | - } | ||
226 | - | ||
227 | - if (message instanceof PcepUpdateMsg) { | ||
228 | - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); | ||
229 | - message.writeTo(buf); | ||
230 | - testupdateMsg = buf.array(); | ||
231 | - | ||
232 | - int iReadLen = buf.writerIndex() - 0; | ||
233 | - testupdateMsg = new byte[iReadLen]; | ||
234 | - buf.readBytes(testupdateMsg, 0, iReadLen); | ||
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 | 175 | ||
176 | + message = reader.readFrom(buffer); | ||
177 | + | ||
178 | + Assert.assertTrue("PcepMessage is not instance of PcUpd", (message instanceof PcepUpdateMsg)); | ||
179 | + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); | ||
180 | + message.writeTo(buf); | ||
181 | + testupdateMsg = buf.array(); | ||
182 | + | ||
183 | + int readLen = buf.writerIndex() - 0; | ||
184 | + testupdateMsg = new byte[readLen]; | ||
185 | + buf.readBytes(testupdateMsg, 0, readLen); | ||
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 { | ||
273 | - message = reader.readFrom(buffer); | ||
274 | - } catch (PcepParseException e) { | ||
275 | - e.printStackTrace(); | ||
276 | - } | ||
277 | - | ||
278 | - if (message instanceof PcepUpdateMsg) { | ||
279 | - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); | ||
280 | - message.writeTo(buf); | ||
281 | - testupdateMsg = buf.array(); | ||
282 | - | ||
283 | - int iReadLen = buf.writerIndex() - 0; | ||
284 | - testupdateMsg = new byte[iReadLen]; | ||
285 | - buf.readBytes(testupdateMsg, 0, iReadLen); | ||
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 | 215 | ||
216 | + message = reader.readFrom(buffer); | ||
217 | + | ||
218 | + Assert.assertTrue("PcepMessage is not instance of PcUpd", (message instanceof PcepUpdateMsg)); | ||
219 | + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); | ||
220 | + message.writeTo(buf); | ||
221 | + testupdateMsg = buf.array(); | ||
222 | + | ||
223 | + int readLen = buf.writerIndex() - 0; | ||
224 | + testupdateMsg = new byte[readLen]; | ||
225 | + buf.readBytes(testupdateMsg, 0, readLen); | ||
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) { | 258 | + |
327 | - e.printStackTrace(); | 259 | + Assert.assertTrue("PcepMessage is not instance of PcUpd", (message instanceof PcepUpdateMsg)); |
328 | - } | 260 | + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); |
329 | - | 261 | + message.writeTo(buf); |
330 | - if (message instanceof PcepUpdateMsg) { | 262 | + testupdateMsg = buf.array(); |
331 | - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); | 263 | + |
332 | - message.writeTo(buf); | 264 | + int readLen = buf.writerIndex() - 0; |
333 | - testupdateMsg = buf.array(); | 265 | + testupdateMsg = new byte[readLen]; |
334 | - | 266 | + buf.readBytes(testupdateMsg, 0, readLen); |
335 | - int iReadLen = buf.writerIndex() - 0; | 267 | + |
336 | - testupdateMsg = new byte[iReadLen]; | 268 | + Assert.assertArrayEquals("PcUpd messages are not equal", updateMsg, testupdateMsg); |
337 | - buf.readBytes(testupdateMsg, 0, iReadLen); | ||
338 | - | ||
339 | - if (Arrays.equals(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) { | 300 | + |
379 | - e.printStackTrace(); | 301 | + Assert.assertTrue("PcepMessage is not instance of PcUpd", (message instanceof PcepUpdateMsg)); |
380 | - } | 302 | + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); |
381 | - | 303 | + message.writeTo(buf); |
382 | - if (message instanceof PcepUpdateMsg) { | 304 | + testupdateMsg = buf.array(); |
383 | - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); | 305 | + |
384 | - message.writeTo(buf); | 306 | + int readLen = buf.writerIndex() - 0; |
385 | - testupdateMsg = buf.array(); | 307 | + testupdateMsg = new byte[readLen]; |
386 | - | 308 | + buf.readBytes(testupdateMsg, 0, readLen); |
387 | - int iReadLen = buf.writerIndex() - 0; | 309 | + Assert.assertArrayEquals("PcUpd messages are not equal", updateMsg, testupdateMsg); |
388 | - testupdateMsg = new byte[iReadLen]; | ||
389 | - buf.readBytes(testupdateMsg, 0, iReadLen); | ||
390 | - | ||
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) { | 341 | + |
431 | - e.printStackTrace(); | 342 | + Assert.assertTrue("PcepMessage is not instance of PcUpd", (message instanceof PcepUpdateMsg)); |
432 | - } | 343 | + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); |
433 | - | 344 | + message.writeTo(buf); |
434 | - if (message instanceof PcepUpdateMsg) { | 345 | + testupdateMsg = buf.array(); |
435 | - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); | 346 | + |
436 | - message.writeTo(buf); | 347 | + int readLen = buf.writerIndex() - 0; |
437 | - testupdateMsg = buf.array(); | 348 | + testupdateMsg = new byte[readLen]; |
438 | - | 349 | + buf.readBytes(testupdateMsg, 0, readLen); |
439 | - int iReadLen = buf.writerIndex() - 0; | 350 | + |
440 | - testupdateMsg = new byte[iReadLen]; | 351 | + Assert.assertArrayEquals("PcUpd messages are not equal", updateMsg, testupdateMsg); |
441 | - buf.readBytes(testupdateMsg, 0, iReadLen); | ||
442 | - | ||
443 | - if (Arrays.equals(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) { | 384 | + |
484 | - e.printStackTrace(); | 385 | + Assert.assertTrue("PcepMessage is not instance of PcUpd", (message instanceof PcepUpdateMsg)); |
485 | - } | 386 | + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); |
486 | - | 387 | + message.writeTo(buf); |
487 | - if (message instanceof PcepUpdateMsg) { | 388 | + testupdateMsg = buf.array(); |
488 | - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); | 389 | + |
489 | - message.writeTo(buf); | 390 | + int readLen = buf.writerIndex() - 0; |
490 | - testupdateMsg = buf.array(); | 391 | + testupdateMsg = new byte[readLen]; |
491 | - | 392 | + buf.readBytes(testupdateMsg, 0, readLen); |
492 | - int iReadLen = buf.writerIndex() - 0; | 393 | + |
493 | - testupdateMsg = new byte[iReadLen]; | 394 | + Assert.assertArrayEquals("PcUpd messages are not equal", updateMsg, testupdateMsg); |
494 | - buf.readBytes(testupdateMsg, 0, iReadLen); | ||
495 | - | ||
496 | - if (Arrays.equals(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) { | 429 | + |
539 | - e.printStackTrace(); | 430 | + Assert.assertTrue("PcepMessage is not instance of PcUpd", (message instanceof PcepUpdateMsg)); |
540 | - } | 431 | + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); |
541 | - | 432 | + message.writeTo(buf); |
542 | - if (message instanceof PcepUpdateMsg) { | 433 | + testupdateMsg = buf.array(); |
543 | - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); | 434 | + |
544 | - message.writeTo(buf); | 435 | + int readLen = buf.writerIndex() - 0; |
545 | - testupdateMsg = buf.array(); | 436 | + testupdateMsg = new byte[readLen]; |
546 | - | 437 | + buf.readBytes(testupdateMsg, 0, readLen); |
547 | - int iReadLen = buf.writerIndex() - 0; | 438 | + |
548 | - testupdateMsg = new byte[iReadLen]; | 439 | + Assert.assertArrayEquals("PcUpd messages are not equal", updateMsg, testupdateMsg); |
549 | - buf.readBytes(testupdateMsg, 0, iReadLen); | ||
550 | - | ||
551 | - if (Arrays.equals(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) { | 475 | + |
595 | - e.printStackTrace(); | 476 | + Assert.assertTrue("PcepMessage is not instance of PcUpd", (message instanceof PcepUpdateMsg)); |
596 | - } | 477 | + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); |
597 | - | 478 | + message.writeTo(buf); |
598 | - if (message instanceof PcepUpdateMsg) { | 479 | + testupdateMsg = buf.array(); |
599 | - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); | 480 | + |
600 | - message.writeTo(buf); | 481 | + int readLen = buf.writerIndex() - 0; |
601 | - testupdateMsg = buf.array(); | 482 | + testupdateMsg = new byte[readLen]; |
602 | - | 483 | + buf.readBytes(testupdateMsg, 0, readLen); |
603 | - int iReadLen = buf.writerIndex() - 0; | 484 | + |
604 | - testupdateMsg = new byte[iReadLen]; | 485 | + Assert.assertArrayEquals("PcUpd messages are not equal", updateMsg, testupdateMsg); |
605 | - buf.readBytes(testupdateMsg, 0, iReadLen); | ||
606 | - | ||
607 | - if (Arrays.equals(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) { | 520 | + |
650 | - e.printStackTrace(); | 521 | + Assert.assertTrue("PcepMessage is not instance of PcUpd", (message instanceof PcepUpdateMsg)); |
651 | - } | 522 | + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); |
652 | - | 523 | + message.writeTo(buf); |
653 | - if (message instanceof PcepUpdateMsg) { | 524 | + testupdateMsg = buf.array(); |
654 | - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); | 525 | + |
655 | - message.writeTo(buf); | 526 | + int readLen = buf.writerIndex() - 0; |
656 | - testupdateMsg = buf.array(); | 527 | + testupdateMsg = new byte[readLen]; |
657 | - | 528 | + buf.readBytes(testupdateMsg, 0, readLen); |
658 | - int iReadLen = buf.writerIndex() - 0; | 529 | + |
659 | - testupdateMsg = new byte[iReadLen]; | 530 | + Assert.assertArrayEquals("PcUpd messages are not equal", updateMsg, testupdateMsg); |
660 | - buf.readBytes(testupdateMsg, 0, iReadLen); | ||
661 | - | ||
662 | - if (Arrays.equals(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) { | 565 | + |
705 | - e.printStackTrace(); | 566 | + Assert.assertTrue("PcepMessage is not instance of PcUpd", (message instanceof PcepUpdateMsg)); |
706 | - } | 567 | + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); |
707 | - | 568 | + message.writeTo(buf); |
708 | - if (message instanceof PcepUpdateMsg) { | 569 | + testupdateMsg = buf.array(); |
709 | - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); | 570 | + |
710 | - message.writeTo(buf); | 571 | + int readLen = buf.writerIndex() - 0; |
711 | - testupdateMsg = buf.array(); | 572 | + testupdateMsg = new byte[readLen]; |
712 | - | 573 | + buf.readBytes(testupdateMsg, 0, readLen); |
713 | - int iReadLen = buf.writerIndex() - 0; | 574 | + |
714 | - testupdateMsg = new byte[iReadLen]; | 575 | + Assert.assertArrayEquals("PcUpd messages are not equal", updateMsg, testupdateMsg); |
715 | - buf.readBytes(testupdateMsg, 0, iReadLen); | ||
716 | - | ||
717 | - if (Arrays.equals(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) { | 609 | + |
759 | - e.printStackTrace(); | 610 | + Assert.assertTrue("PcepMessage is not instance of PcUpd", (message instanceof PcepUpdateMsg)); |
760 | - } | 611 | + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); |
761 | - | 612 | + message.writeTo(buf); |
762 | - if (message instanceof PcepUpdateMsg) { | 613 | + testupdateMsg = buf.array(); |
763 | - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); | 614 | + |
764 | - message.writeTo(buf); | 615 | + int readLen = buf.writerIndex() - 0; |
765 | - testupdateMsg = buf.array(); | 616 | + testupdateMsg = new byte[readLen]; |
766 | - | 617 | + buf.readBytes(testupdateMsg, 0, readLen); |
767 | - int iReadLen = buf.writerIndex() - 0; | 618 | + |
768 | - testupdateMsg = new byte[iReadLen]; | 619 | + Assert.assertArrayEquals("PcUpd messages are not equal", updateMsg, testupdateMsg); |
769 | - buf.readBytes(testupdateMsg, 0, iReadLen); | ||
770 | - | ||
771 | - if (Arrays.equals(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) { | 653 | + |
813 | - e.printStackTrace(); | 654 | + Assert.assertTrue("PcepMessage is not instance of PcUpd", (message instanceof PcepUpdateMsg)); |
814 | - } | 655 | + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); |
815 | - | 656 | + message.writeTo(buf); |
816 | - if (message instanceof PcepUpdateMsg) { | 657 | + testupdateMsg = buf.array(); |
817 | - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); | 658 | + |
818 | - message.writeTo(buf); | 659 | + int readLen = buf.writerIndex() - 0; |
819 | - testupdateMsg = buf.array(); | 660 | + testupdateMsg = new byte[readLen]; |
820 | - | 661 | + buf.readBytes(testupdateMsg, 0, readLen); |
821 | - int iReadLen = buf.writerIndex() - 0; | 662 | + |
822 | - testupdateMsg = new byte[iReadLen]; | 663 | + Assert.assertArrayEquals("PcUpd messages are not equal", updateMsg, testupdateMsg); |
823 | - buf.readBytes(testupdateMsg, 0, iReadLen); | ||
824 | - | ||
825 | - if (Arrays.equals(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) { | 696 | + |
866 | - e.printStackTrace(); | 697 | + Assert.assertTrue("PcepMessage is not instance of PcUpd", (message instanceof PcepUpdateMsg)); |
867 | - } | 698 | + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); |
868 | - | 699 | + message.writeTo(buf); |
869 | - if (message instanceof PcepUpdateMsg) { | 700 | + testupdateMsg = buf.array(); |
870 | - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); | 701 | + |
871 | - message.writeTo(buf); | 702 | + int readLen = buf.writerIndex() - 0; |
872 | - testupdateMsg = buf.array(); | 703 | + testupdateMsg = new byte[readLen]; |
873 | - | 704 | + buf.readBytes(testupdateMsg, 0, readLen); |
874 | - int iReadLen = buf.writerIndex() - 0; | 705 | + |
875 | - testupdateMsg = new byte[iReadLen]; | 706 | + Assert.assertArrayEquals("PcUpd messages are not equal", updateMsg, testupdateMsg); |
876 | - buf.readBytes(testupdateMsg, 0, iReadLen); | ||
877 | - | ||
878 | - if (Arrays.equals(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) { | 738 | + |
918 | - e.printStackTrace(); | 739 | + Assert.assertTrue("PcepMessage is not instance of PcUpd", (message instanceof PcepUpdateMsg)); |
919 | - } | 740 | + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); |
920 | - | 741 | + message.writeTo(buf); |
921 | - if (message instanceof PcepUpdateMsg) { | 742 | + testupdateMsg = buf.array(); |
922 | - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); | 743 | + |
923 | - message.writeTo(buf); | 744 | + int readLen = buf.writerIndex() - 0; |
924 | - testupdateMsg = buf.array(); | 745 | + testupdateMsg = new byte[readLen]; |
925 | - | 746 | + buf.readBytes(testupdateMsg, 0, readLen); |
926 | - int iReadLen = buf.writerIndex() - 0; | 747 | + |
927 | - testupdateMsg = new byte[iReadLen]; | 748 | + Assert.assertArrayEquals("PcUpd messages are not equal", updateMsg, testupdateMsg); |
928 | - buf.readBytes(testupdateMsg, 0, iReadLen); | ||
929 | - | ||
930 | - if (Arrays.equals(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) { | 779 | + |
969 | - e.printStackTrace(); | 780 | + Assert.assertTrue("PcepMessage is not instance of PcUpd", (message instanceof PcepUpdateMsg)); |
970 | - } | 781 | + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); |
971 | - | 782 | + message.writeTo(buf); |
972 | - if (message instanceof PcepUpdateMsg) { | 783 | + testupdateMsg = buf.array(); |
973 | - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); | 784 | + |
974 | - message.writeTo(buf); | 785 | + int readLen = buf.writerIndex() - 0; |
975 | - testupdateMsg = buf.array(); | 786 | + testupdateMsg = new byte[readLen]; |
976 | - | 787 | + buf.readBytes(testupdateMsg, 0, readLen); |
977 | - int iReadLen = buf.writerIndex() - 0; | 788 | + |
978 | - testupdateMsg = new byte[iReadLen]; | 789 | + Assert.assertArrayEquals("PcUpd messages are not equal", updateMsg, testupdateMsg); |
979 | - buf.readBytes(testupdateMsg, 0, iReadLen); | ||
980 | - | ||
981 | - if (Arrays.equals(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) { | 821 | + |
1021 | - e.printStackTrace(); | 822 | + Assert.assertTrue("PcepMessage is not instance of PcUpd", (message instanceof PcepUpdateMsg)); |
1022 | - } | 823 | + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); |
1023 | - | 824 | + message.writeTo(buf); |
1024 | - if (message instanceof PcepUpdateMsg) { | 825 | + testupdateMsg = buf.array(); |
1025 | - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); | 826 | + |
1026 | - message.writeTo(buf); | 827 | + int readLen = buf.writerIndex() - 0; |
1027 | - testupdateMsg = buf.array(); | 828 | + testupdateMsg = new byte[readLen]; |
1028 | - | 829 | + buf.readBytes(testupdateMsg, 0, readLen); |
1029 | - int iReadLen = buf.writerIndex() - 0; | 830 | + |
1030 | - testupdateMsg = new byte[iReadLen]; | 831 | + Assert.assertArrayEquals("PcUpd messages are not equal", updateMsg, testupdateMsg); |
1031 | - buf.readBytes(testupdateMsg, 0, iReadLen); | ||
1032 | - | ||
1033 | - if (Arrays.equals(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) { | 868 | + |
1078 | - e.printStackTrace(); | 869 | + Assert.assertTrue("PcepMessage is not instance of PcUpd", (message instanceof PcepUpdateMsg)); |
1079 | - } | 870 | + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); |
1080 | - | 871 | + message.writeTo(buf); |
1081 | - if (message instanceof PcepUpdateMsg) { | 872 | + testupdateMsg = buf.array(); |
1082 | - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); | 873 | + |
1083 | - message.writeTo(buf); | 874 | + int readLen = buf.writerIndex() - 0; |
1084 | - testupdateMsg = buf.array(); | 875 | + testupdateMsg = new byte[readLen]; |
1085 | - | 876 | + buf.readBytes(testupdateMsg, 0, readLen); |
1086 | - int iReadLen = buf.writerIndex() - 0; | 877 | + |
1087 | - testupdateMsg = new byte[iReadLen]; | 878 | + Assert.assertArrayEquals("PcUpd messages are not equal", updateMsg, testupdateMsg); |
1088 | - buf.readBytes(testupdateMsg, 0, iReadLen); | ||
1089 | - | ||
1090 | - if (Arrays.equals(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) { | 909 | + |
1129 | - e.printStackTrace(); | 910 | + Assert.assertTrue("PcepMessage is not instance of PcUpd", (message instanceof PcepUpdateMsg)); |
1130 | - } | 911 | + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); |
1131 | - | 912 | + message.writeTo(buf); |
1132 | - if (message instanceof PcepUpdateMsg) { | 913 | + testupdateMsg = buf.array(); |
1133 | - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); | 914 | + |
1134 | - message.writeTo(buf); | 915 | + int readLen = buf.writerIndex() - 0; |
1135 | - testupdateMsg = buf.array(); | 916 | + testupdateMsg = new byte[readLen]; |
1136 | - | 917 | + buf.readBytes(testupdateMsg, 0, readLen); |
1137 | - int iReadLen = buf.writerIndex() - 0; | 918 | + |
1138 | - testupdateMsg = new byte[iReadLen]; | 919 | + Assert.assertArrayEquals("PcUpd messages are not equal", updateMsg, testupdateMsg); |
1139 | - buf.readBytes(testupdateMsg, 0, iReadLen); | ||
1140 | - | ||
1141 | - if (Arrays.equals(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) { | 952 | + |
1182 | - e.printStackTrace(); | 953 | + Assert.assertTrue("PcepMessage is not instance of PcUpd", (message instanceof PcepUpdateMsg)); |
1183 | - } | 954 | + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); |
1184 | - | 955 | + message.writeTo(buf); |
1185 | - if (message instanceof PcepUpdateMsg) { | 956 | + testupdateMsg = buf.array(); |
1186 | - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); | 957 | + |
1187 | - message.writeTo(buf); | 958 | + int readLen = buf.writerIndex() - 0; |
1188 | - testupdateMsg = buf.array(); | 959 | + testupdateMsg = new byte[readLen]; |
1189 | - | 960 | + buf.readBytes(testupdateMsg, 0, readLen); |
1190 | - int iReadLen = buf.writerIndex() - 0; | 961 | + |
1191 | - testupdateMsg = new byte[iReadLen]; | 962 | + Assert.assertArrayEquals("PcUpd messages are not equal", updateMsg, testupdateMsg); |
1192 | - buf.readBytes(testupdateMsg, 0, iReadLen); | ||
1193 | - | ||
1194 | - if (Arrays.equals(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) { | 996 | + |
1236 | - e.printStackTrace(); | 997 | + Assert.assertTrue("PcepMessage is not instance of PcUpd", (message instanceof PcepUpdateMsg)); |
1237 | - } | 998 | + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); |
1238 | - | 999 | + message.writeTo(buf); |
1239 | - if (message instanceof PcepUpdateMsg) { | 1000 | + testupdateMsg = buf.array(); |
1240 | - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); | 1001 | + |
1241 | - message.writeTo(buf); | 1002 | + int readLen = buf.writerIndex() - 0; |
1242 | - testupdateMsg = buf.array(); | 1003 | + testupdateMsg = new byte[readLen]; |
1243 | - | 1004 | + buf.readBytes(testupdateMsg, 0, readLen); |
1244 | - int iReadLen = buf.writerIndex() - 0; | 1005 | + |
1245 | - testupdateMsg = new byte[iReadLen]; | 1006 | + Assert.assertArrayEquals("PcUpd messages are not equal", updateMsg, testupdateMsg); |
1246 | - buf.readBytes(testupdateMsg, 0, iReadLen); | ||
1247 | - | ||
1248 | - if (Arrays.equals(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) { | 1041 | + |
1291 | - e.printStackTrace(); | 1042 | + Assert.assertTrue("PcepMessage is not instance of PcUpd", (message instanceof PcepUpdateMsg)); |
1292 | - } | 1043 | + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); |
1293 | - | 1044 | + message.writeTo(buf); |
1294 | - if (message instanceof PcepUpdateMsg) { | 1045 | + testupdateMsg = buf.array(); |
1295 | - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); | 1046 | + |
1296 | - message.writeTo(buf); | 1047 | + int readLen = buf.writerIndex() - 0; |
1297 | - testupdateMsg = buf.array(); | 1048 | + testupdateMsg = new byte[readLen]; |
1298 | - | 1049 | + buf.readBytes(testupdateMsg, 0, readLen); |
1299 | - int iReadLen = buf.writerIndex() - 0; | 1050 | + |
1300 | - testupdateMsg = new byte[iReadLen]; | 1051 | + Assert.assertArrayEquals("PcUpd messages are not equal", updateMsg, testupdateMsg); |
1301 | - buf.readBytes(testupdateMsg, 0, iReadLen); | ||
1302 | - | ||
1303 | - if (Arrays.equals(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) { | 1086 | + |
1346 | - e.printStackTrace(); | 1087 | + Assert.assertTrue("PcepMessage is not instance of PcUpd", (message instanceof PcepUpdateMsg)); |
1347 | - } | 1088 | + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); |
1348 | - | 1089 | + message.writeTo(buf); |
1349 | - if (message instanceof PcepUpdateMsg) { | 1090 | + testupdateMsg = buf.array(); |
1350 | - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); | 1091 | + |
1351 | - message.writeTo(buf); | 1092 | + int readLen = buf.writerIndex() - 0; |
1352 | - testupdateMsg = buf.array(); | 1093 | + testupdateMsg = new byte[readLen]; |
1353 | - | 1094 | + buf.readBytes(testupdateMsg, 0, readLen); |
1354 | - int iReadLen = buf.writerIndex() - 0; | 1095 | + |
1355 | - testupdateMsg = new byte[iReadLen]; | 1096 | + Assert.assertArrayEquals("PcUpd messages are not equal", updateMsg, testupdateMsg); |
1356 | - buf.readBytes(testupdateMsg, 0, iReadLen); | ||
1357 | - | ||
1358 | - if (Arrays.equals(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 { | 1131 | + |
1400 | - message = reader.readFrom(buffer); | 1132 | + message = reader.readFrom(buffer); |
1401 | - } catch (PcepParseException e) { | 1133 | + Assert.assertTrue("PcepMessage is not instance of PcUpd", (message instanceof PcepUpdateMsg)); |
1402 | - e.printStackTrace(); | 1134 | + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); |
1403 | - } | 1135 | + message.writeTo(buf); |
1404 | - | 1136 | + testupdateMsg = buf.array(); |
1405 | - if (message instanceof PcepUpdateMsg) { | 1137 | + |
1406 | - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); | 1138 | + int readLen = buf.writerIndex() - 0; |
1407 | - message.writeTo(buf); | 1139 | + testupdateMsg = new byte[readLen]; |
1408 | - testupdateMsg = buf.array(); | 1140 | + buf.readBytes(testupdateMsg, 0, readLen); |
1409 | - | 1141 | + |
1410 | - int iReadLen = buf.writerIndex() - 0; | 1142 | + Assert.assertArrayEquals("PcUpd messages are not equal", updateMsg, testupdateMsg); |
1411 | - testupdateMsg = new byte[iReadLen]; | ||
1412 | - buf.readBytes(testupdateMsg, 0, iReadLen); | ||
1413 | - | ||
1414 | - if (Arrays.equals(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) { | 1179 | + |
1458 | - e.printStackTrace(); | 1180 | + Assert.assertTrue("PcepMessage is not instance of PcUpd", (message instanceof PcepUpdateMsg)); |
1459 | - } | 1181 | + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); |
1460 | - | 1182 | + message.writeTo(buf); |
1461 | - if (message instanceof PcepUpdateMsg) { | 1183 | + testupdateMsg = buf.array(); |
1462 | - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); | 1184 | + |
1463 | - message.writeTo(buf); | 1185 | + int readLen = buf.writerIndex() - 0; |
1464 | - testupdateMsg = buf.array(); | 1186 | + testupdateMsg = new byte[readLen]; |
1465 | - | 1187 | + buf.readBytes(testupdateMsg, 0, readLen); |
1466 | - int iReadLen = buf.writerIndex() - 0; | 1188 | + |
1467 | - testupdateMsg = new byte[iReadLen]; | 1189 | + Assert.assertArrayEquals("PcUpd messages are not equal", updateMsg, testupdateMsg); |
1468 | - buf.readBytes(testupdateMsg, 0, iReadLen); | ||
1469 | - | ||
1470 | - if (Arrays.equals(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) { | 1227 | + |
1515 | - e.printStackTrace(); | 1228 | + Assert.assertTrue("PcepMessage is not instance of PcUpd", (message instanceof PcepUpdateMsg)); |
1516 | - } | 1229 | + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); |
1517 | - | 1230 | + message.writeTo(buf); |
1518 | - if (message instanceof PcepUpdateMsg) { | 1231 | + testupdateMsg = buf.array(); |
1519 | - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); | 1232 | + |
1520 | - message.writeTo(buf); | 1233 | + int readLen = buf.writerIndex() - 0; |
1521 | - testupdateMsg = buf.array(); | 1234 | + testupdateMsg = new byte[readLen]; |
1522 | - | 1235 | + buf.readBytes(testupdateMsg, 0, readLen); |
1523 | - int iReadLen = buf.writerIndex() - 0; | 1236 | + |
1524 | - testupdateMsg = new byte[iReadLen]; | 1237 | + Assert.assertArrayEquals("PcUpd messages are not equal", updateMsg, testupdateMsg); |
1525 | - buf.readBytes(testupdateMsg, 0, iReadLen); | ||
1526 | - | ||
1527 | - if (Arrays.equals(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) { | 1271 | + |
1569 | - e.printStackTrace(); | 1272 | + Assert.assertTrue("PcepMessage is not instance of PcUpd", (message instanceof PcepUpdateMsg)); |
1570 | - } | 1273 | + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); |
1571 | - | 1274 | + message.writeTo(buf); |
1572 | - if (message instanceof PcepUpdateMsg) { | 1275 | + testupdateMsg = buf.array(); |
1573 | - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); | 1276 | + |
1574 | - message.writeTo(buf); | 1277 | + int readLen = buf.writerIndex() - 0; |
1575 | - testupdateMsg = buf.array(); | 1278 | + testupdateMsg = new byte[readLen]; |
1576 | - | 1279 | + buf.readBytes(testupdateMsg, 0, readLen); |
1577 | - int iReadLen = buf.writerIndex() - 0; | 1280 | + |
1578 | - testupdateMsg = new byte[iReadLen]; | 1281 | + Assert.assertArrayEquals("PcUpd messages are not equal", updateMsg, testupdateMsg); |
1579 | - buf.readBytes(testupdateMsg, 0, iReadLen); | ||
1580 | - | ||
1581 | - if (Arrays.equals(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) { | 1312 | + |
1620 | - e.printStackTrace(); | 1313 | + Assert.assertTrue("PcepMessage is not instance of PcUpd", (message instanceof PcepUpdateMsg)); |
1621 | - } | 1314 | + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); |
1622 | - | 1315 | + message.writeTo(buf); |
1623 | - if (message instanceof PcepUpdateMsg) { | 1316 | + testupdateMsg = buf.array(); |
1624 | - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); | 1317 | + |
1625 | - message.writeTo(buf); | 1318 | + int readLen = buf.writerIndex() - 0; |
1626 | - testupdateMsg = buf.array(); | 1319 | + testupdateMsg = new byte[readLen]; |
1627 | - | 1320 | + buf.readBytes(testupdateMsg, 0, readLen); |
1628 | - int iReadLen = buf.writerIndex() - 0; | 1321 | + |
1629 | - testupdateMsg = new byte[iReadLen]; | 1322 | + Assert.assertArrayEquals("PcUpd messages are not equal", updateMsg, testupdateMsg); |
1630 | - buf.readBytes(testupdateMsg, 0, iReadLen); | ||
1631 | - | ||
1632 | - if (Arrays.equals(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) { | 1354 | + |
1672 | - e.printStackTrace(); | 1355 | + Assert.assertTrue("PcepMessage is not instance of PcUpd", (message instanceof PcepUpdateMsg)); |
1673 | - } | 1356 | + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); |
1674 | - | 1357 | + message.writeTo(buf); |
1675 | - if (message instanceof PcepUpdateMsg) { | 1358 | + testupdateMsg = buf.array(); |
1676 | - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); | 1359 | + |
1677 | - message.writeTo(buf); | 1360 | + int readLen = buf.writerIndex() - 0; |
1678 | - testupdateMsg = buf.array(); | 1361 | + testupdateMsg = new byte[readLen]; |
1679 | - | 1362 | + buf.readBytes(testupdateMsg, 0, readLen); |
1680 | - int iReadLen = buf.writerIndex() - 0; | 1363 | + |
1681 | - testupdateMsg = new byte[iReadLen]; | 1364 | + Assert.assertArrayEquals("PcUpd messages are not equal", updateMsg, testupdateMsg); |
1682 | - buf.readBytes(testupdateMsg, 0, iReadLen); | ||
1683 | - | ||
1684 | - if (Arrays.equals(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) { | 1395 | + |
1723 | - e.printStackTrace(); | 1396 | + Assert.assertTrue("PcepMessage is not instance of PcUpd", (message instanceof PcepUpdateMsg)); |
1724 | - } | 1397 | + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); |
1725 | - | 1398 | + message.writeTo(buf); |
1726 | - if (message instanceof PcepUpdateMsg) { | 1399 | + testupdateMsg = buf.array(); |
1727 | - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); | 1400 | + |
1728 | - message.writeTo(buf); | 1401 | + int readLen = buf.writerIndex() - 0; |
1729 | - testupdateMsg = buf.array(); | 1402 | + testupdateMsg = new byte[readLen]; |
1730 | - | 1403 | + buf.readBytes(testupdateMsg, 0, readLen); |
1731 | - int iReadLen = buf.writerIndex() - 0; | 1404 | + |
1732 | - testupdateMsg = new byte[iReadLen]; | 1405 | + Assert.assertArrayEquals("PcUpd messages are not equal", updateMsg, testupdateMsg); |
1733 | - buf.readBytes(testupdateMsg, 0, iReadLen); | ||
1734 | - | ||
1735 | - if (Arrays.equals(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) { | 1437 | + |
1775 | - e.printStackTrace(); | 1438 | + Assert.assertTrue("PcepMessage is not instance of PcUpd", (message instanceof PcepUpdateMsg)); |
1776 | - } | 1439 | + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); |
1777 | - | 1440 | + message.writeTo(buf); |
1778 | - if (message instanceof PcepUpdateMsg) { | 1441 | + testupdateMsg = buf.array(); |
1779 | - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); | 1442 | + |
1780 | - message.writeTo(buf); | 1443 | + int readLen = buf.writerIndex() - 0; |
1781 | - testupdateMsg = buf.array(); | 1444 | + testupdateMsg = new byte[readLen]; |
1782 | - | 1445 | + buf.readBytes(testupdateMsg, 0, readLen); |
1783 | - int iReadLen = buf.writerIndex() - 0; | 1446 | + |
1784 | - testupdateMsg = new byte[iReadLen]; | 1447 | + Assert.assertArrayEquals("PcUpd messages are not equal", updateMsg, testupdateMsg); |
1785 | - buf.readBytes(testupdateMsg, 0, iReadLen); | ||
1786 | - | ||
1787 | - if (Arrays.equals(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) { | 1480 | + |
1828 | - e.printStackTrace(); | 1481 | + Assert.assertTrue("PcepMessage is not instance of PcUpd", (message instanceof PcepUpdateMsg)); |
1829 | - } | 1482 | + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); |
1830 | - | 1483 | + message.writeTo(buf); |
1831 | - if (message instanceof PcepUpdateMsg) { | 1484 | + testupdateMsg = buf.array(); |
1832 | - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); | 1485 | + |
1833 | - message.writeTo(buf); | 1486 | + int readLen = buf.writerIndex() - 0; |
1834 | - testupdateMsg = buf.array(); | 1487 | + testupdateMsg = new byte[readLen]; |
1835 | - | 1488 | + buf.readBytes(testupdateMsg, 0, readLen); |
1836 | - int iReadLen = buf.writerIndex() - 0; | 1489 | + |
1837 | - testupdateMsg = new byte[iReadLen]; | 1490 | + Assert.assertArrayEquals("PcUpd messages are not equal", updateMsg, testupdateMsg); |
1838 | - buf.readBytes(testupdateMsg, 0, iReadLen); | ||
1839 | - | ||
1840 | - if (Arrays.equals(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(); | 69 | + |
82 | - } | 70 | + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); |
83 | - | 71 | + message.writeTo(buf); |
84 | - if (message instanceof PcepUpdateMsg) { | 72 | + testupdateMsg = buf.array(); |
85 | - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); | 73 | + |
86 | - message.writeTo(buf); | 74 | + int readLen = buf.writerIndex() - 0; |
87 | - testupdateMsg = buf.array(); | 75 | + testupdateMsg = new byte[readLen]; |
88 | - | 76 | + buf.readBytes(testupdateMsg, 0, readLen); |
89 | - int iReadLen = buf.writerIndex() - 0; | 77 | + |
90 | - testupdateMsg = new byte[iReadLen]; | 78 | + Assert.assertArrayEquals("PcepUpdatemsg messages are not equal", updateMsg, testupdateMsg); |
91 | - buf.readBytes(testupdateMsg, 0, iReadLen); | ||
92 | - | ||
93 | - if (Arrays.equals(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) { | 111 | + |
131 | - e.printStackTrace(); | 112 | + Assert.assertTrue("PcepMessage is not instance of PcepUpdateMsg", message instanceof PcepUpdateMsg); |
132 | - } | 113 | + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); |
133 | - | 114 | + message.writeTo(buf); |
134 | - if (message instanceof PcepUpdateMsg) { | 115 | + testupdateMsg = buf.array(); |
135 | - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); | 116 | + |
136 | - message.writeTo(buf); | 117 | + int readLen = buf.writerIndex() - 0; |
137 | - testupdateMsg = buf.array(); | 118 | + testupdateMsg = new byte[readLen]; |
138 | - | 119 | + buf.readBytes(testupdateMsg, 0, readLen); |
139 | - int iReadLen = buf.writerIndex() - 0; | 120 | + |
140 | - testupdateMsg = new byte[iReadLen]; | 121 | + Assert.assertArrayEquals("PcepUpdatemsg messages are not equal", updateMsg, testupdateMsg); |
141 | - buf.readBytes(testupdateMsg, 0, iReadLen); | ||
142 | - | ||
143 | - if (Arrays.equals(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) { | 151 | + |
178 | - e.printStackTrace(); | 152 | + Assert.assertTrue("PcepMessage is not instance of PcepUpdateMsg", message instanceof PcepUpdateMsg); |
179 | - } | 153 | + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); |
180 | - | 154 | + message.writeTo(buf); |
181 | - if (message instanceof PcepUpdateMsg) { | 155 | + testupdateMsg = buf.array(); |
182 | - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); | 156 | + |
183 | - message.writeTo(buf); | 157 | + int readLen = buf.writerIndex() - 0; |
184 | - testupdateMsg = buf.array(); | 158 | + testupdateMsg = new byte[readLen]; |
185 | - | 159 | + buf.readBytes(testupdateMsg, 0, readLen); |
186 | - int iReadLen = buf.writerIndex() - 0; | 160 | + |
187 | - testupdateMsg = new byte[iReadLen]; | 161 | + Assert.assertArrayEquals("PcepUpdatemsg messages are not equal", updateMsg, testupdateMsg); |
188 | - buf.readBytes(testupdateMsg, 0, iReadLen); | ||
189 | - | ||
190 | - if (Arrays.equals(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) { | 192 | + |
226 | - e.printStackTrace(); | 193 | + Assert.assertTrue("PcepMessage is not instance of PcepUpdateMsg", message instanceof PcepUpdateMsg); |
227 | - } | 194 | + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); |
228 | - | 195 | + message.writeTo(buf); |
229 | - if (message instanceof PcepUpdateMsg) { | 196 | + testupdateMsg = buf.array(); |
230 | - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); | 197 | + |
231 | - message.writeTo(buf); | 198 | + int readLen = buf.writerIndex() - 0; |
232 | - testupdateMsg = buf.array(); | 199 | + testupdateMsg = new byte[readLen]; |
233 | - | 200 | + buf.readBytes(testupdateMsg, 0, readLen); |
234 | - int iReadLen = buf.writerIndex() - 0; | 201 | + |
235 | - testupdateMsg = new byte[iReadLen]; | 202 | + Assert.assertArrayEquals("PcepUpdatemsg messages are not equal", updateMsg, testupdateMsg); |
236 | - buf.readBytes(testupdateMsg, 0, iReadLen); | ||
237 | - | ||
238 | - if (Arrays.equals(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) { | 234 | + |
275 | - e.printStackTrace(); | 235 | + Assert.assertTrue("PcepMessage is not instance of PcepUpdateMsg", message instanceof PcepUpdateMsg); |
276 | - } | 236 | + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); |
277 | - | 237 | + message.writeTo(buf); |
278 | - if (message instanceof PcepUpdateMsg) { | 238 | + testupdateMsg = buf.array(); |
279 | - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); | 239 | + |
280 | - message.writeTo(buf); | 240 | + int readLen = buf.writerIndex() - 0; |
281 | - testupdateMsg = buf.array(); | 241 | + testupdateMsg = new byte[readLen]; |
282 | - | 242 | + buf.readBytes(testupdateMsg, 0, readLen); |
283 | - int iReadLen = buf.writerIndex() - 0; | 243 | + |
284 | - testupdateMsg = new byte[iReadLen]; | 244 | + Assert.assertArrayEquals("PcepUpdatemsg messages are not equal", updateMsg, testupdateMsg); |
285 | - buf.readBytes(testupdateMsg, 0, iReadLen); | ||
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 | } | 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) { | 275 | + |
323 | - e.printStackTrace(); | 276 | + Assert.assertTrue("PcepMessage is not instance of PcepUpdateMsg", message instanceof PcepUpdateMsg); |
324 | - } | 277 | + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); |
325 | - | 278 | + message.writeTo(buf); |
326 | - if (message instanceof PcepUpdateMsg) { | 279 | + testupdateMsg = buf.array(); |
327 | - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); | 280 | + |
328 | - message.writeTo(buf); | 281 | + int readLen = buf.writerIndex() - 0; |
329 | - testupdateMsg = buf.array(); | 282 | + testupdateMsg = new byte[readLen]; |
330 | - | 283 | + buf.readBytes(testupdateMsg, 0, readLen); |
331 | - int iReadLen = buf.writerIndex() - 0; | 284 | + |
332 | - testupdateMsg = new byte[iReadLen]; | 285 | + Assert.assertArrayEquals("PcepUpdatemsg messages are not equal", updateMsg, testupdateMsg); |
333 | - buf.readBytes(testupdateMsg, 0, iReadLen); | ||
334 | - | ||
335 | - if (Arrays.equals(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) { | 317 | + |
372 | - e.printStackTrace(); | 318 | + Assert.assertTrue("PcepMessage is not instance of PcepUpdateMsg", message instanceof PcepUpdateMsg); |
373 | - } | 319 | + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); |
374 | - | 320 | + message.writeTo(buf); |
375 | - if (message instanceof PcepUpdateMsg) { | 321 | + testupdateMsg = buf.array(); |
376 | - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); | 322 | + |
377 | - message.writeTo(buf); | 323 | + int readLen = buf.writerIndex() - 0; |
378 | - testupdateMsg = buf.array(); | 324 | + testupdateMsg = new byte[readLen]; |
379 | - | 325 | + buf.readBytes(testupdateMsg, 0, readLen); |
380 | - int iReadLen = buf.writerIndex() - 0; | 326 | + |
381 | - testupdateMsg = new byte[iReadLen]; | 327 | + Assert.assertArrayEquals("PcepUpdatemsg messages are not equal", updateMsg, testupdateMsg); |
382 | - buf.readBytes(testupdateMsg, 0, iReadLen); | ||
383 | - | ||
384 | - if (Arrays.equals(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) { | 359 | + |
421 | - e.printStackTrace(); | 360 | + Assert.assertTrue("PcepMessage is not instance of PcepUpdateMsg", message instanceof PcepUpdateMsg); |
422 | - } | 361 | + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); |
423 | - | 362 | + message.writeTo(buf); |
424 | - if (message instanceof PcepUpdateMsg) { | 363 | + testupdateMsg = buf.array(); |
425 | - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); | 364 | + |
426 | - message.writeTo(buf); | 365 | + int readLen = buf.writerIndex() - 0; |
427 | - testupdateMsg = buf.array(); | 366 | + testupdateMsg = new byte[readLen]; |
428 | - | 367 | + buf.readBytes(testupdateMsg, 0, readLen); |
429 | - int iReadLen = buf.writerIndex() - 0; | 368 | + |
430 | - testupdateMsg = new byte[iReadLen]; | 369 | + Assert.assertArrayEquals("PcepUpdatemsg messages are not equal", updateMsg, testupdateMsg); |
431 | - buf.readBytes(testupdateMsg, 0, iReadLen); | ||
432 | - | ||
433 | - if (Arrays.equals(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) { | 400 | + |
469 | - e.printStackTrace(); | 401 | + Assert.assertTrue("PcepMessage is not instance of PcepUpdateMsg", message instanceof PcepUpdateMsg); |
470 | - } | 402 | + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); |
471 | - | 403 | + message.writeTo(buf); |
472 | - if (message instanceof PcepUpdateMsg) { | 404 | + testupdateMsg = buf.array(); |
473 | - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); | 405 | + |
474 | - message.writeTo(buf); | 406 | + int readLen = buf.writerIndex() - 0; |
475 | - testupdateMsg = buf.array(); | 407 | + testupdateMsg = new byte[readLen]; |
476 | - | 408 | + buf.readBytes(testupdateMsg, 0, readLen); |
477 | - int iReadLen = buf.writerIndex() - 0; | 409 | + |
478 | - testupdateMsg = new byte[iReadLen]; | 410 | + Assert.assertArrayEquals("PcepUpdatemsg messages are not equal", updateMsg, testupdateMsg); |
479 | - buf.readBytes(testupdateMsg, 0, iReadLen); | ||
480 | - | ||
481 | - if (Arrays.equals(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) { | 440 | + |
516 | - e.printStackTrace(); | 441 | + Assert.assertTrue("PcepMessage is not instance of PcepUpdateMsg", message instanceof PcepUpdateMsg); |
517 | - } | 442 | + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); |
518 | - | 443 | + message.writeTo(buf); |
519 | - if (message instanceof PcepUpdateMsg) { | 444 | + testupdateMsg = buf.array(); |
520 | - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); | 445 | + |
521 | - message.writeTo(buf); | 446 | + int readLen = buf.writerIndex() - 0; |
522 | - testupdateMsg = buf.array(); | 447 | + testupdateMsg = new byte[readLen]; |
523 | - | 448 | + buf.readBytes(testupdateMsg, 0, readLen); |
524 | - int iReadLen = buf.writerIndex() - 0; | 449 | + |
525 | - testupdateMsg = new byte[iReadLen]; | 450 | + Assert.assertArrayEquals("PcepUpdatemsg messages are not equal", updateMsg, testupdateMsg); |
526 | - buf.readBytes(testupdateMsg, 0, iReadLen); | ||
527 | - | ||
528 | - if (Arrays.equals(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 { | 479 | + |
562 | - message = reader.readFrom(buffer); | 480 | + Assert.assertTrue("PcepMessage is not instance of PcepUpdateMsg", message instanceof PcepUpdateMsg); |
563 | - } catch (PcepParseException e) { | 481 | + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); |
564 | - e.printStackTrace(); | 482 | + message.writeTo(buf); |
565 | - } | 483 | + testupdateMsg = buf.array(); |
566 | - | 484 | + |
567 | - if (message instanceof PcepUpdateMsg) { | 485 | + int readLen = buf.writerIndex() - 0; |
568 | - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); | 486 | + testupdateMsg = new byte[readLen]; |
569 | - message.writeTo(buf); | 487 | + buf.readBytes(testupdateMsg, 0, readLen); |
570 | - testupdateMsg = buf.array(); | 488 | + |
571 | - | 489 | + Assert.assertArrayEquals("PcepUpdatemsg messages are not equal", updateMsg, testupdateMsg); |
572 | - int iReadLen = buf.writerIndex() - 0; | ||
573 | - testupdateMsg = new byte[iReadLen]; | ||
574 | - buf.readBytes(testupdateMsg, 0, iReadLen); | ||
575 | - | ||
576 | - if (Arrays.equals(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) { | 519 | + |
611 | - e.printStackTrace(); | 520 | + Assert.assertTrue("PcepMessage is not instance of PcepUpdateMsg", message instanceof PcepUpdateMsg); |
612 | - } | 521 | + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); |
613 | - | 522 | + message.writeTo(buf); |
614 | - if (message instanceof PcepUpdateMsg) { | 523 | + testupdateMsg = buf.array(); |
615 | - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); | 524 | + |
616 | - message.writeTo(buf); | 525 | + int readLen = buf.writerIndex() - 0; |
617 | - testupdateMsg = buf.array(); | 526 | + testupdateMsg = new byte[readLen]; |
618 | - | 527 | + buf.readBytes(testupdateMsg, 0, readLen); |
619 | - int iReadLen = buf.writerIndex() - 0; | 528 | + |
620 | - testupdateMsg = new byte[iReadLen]; | 529 | + Assert.assertArrayEquals("PcepUpdatemsg messages are not equal", updateMsg, testupdateMsg); |
621 | - buf.readBytes(testupdateMsg, 0, iReadLen); | ||
622 | - | ||
623 | - if (Arrays.equals(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) { | 560 | + |
659 | - e.printStackTrace(); | 561 | + Assert.assertTrue("PcepMessage is not instance of PcepUpdateMsg", message instanceof PcepUpdateMsg); |
660 | - } | 562 | + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); |
661 | - | 563 | + message.writeTo(buf); |
662 | - if (message instanceof PcepUpdateMsg) { | 564 | + testupdateMsg = buf.array(); |
663 | - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); | 565 | + |
664 | - message.writeTo(buf); | 566 | + int readLen = buf.writerIndex() - 0; |
665 | - testupdateMsg = buf.array(); | 567 | + testupdateMsg = new byte[readLen]; |
666 | - | 568 | + buf.readBytes(testupdateMsg, 0, readLen); |
667 | - int iReadLen = buf.writerIndex() - 0; | 569 | + |
668 | - testupdateMsg = new byte[iReadLen]; | 570 | + Assert.assertArrayEquals("PcepUpdatemsg messages are not equal", updateMsg, testupdateMsg); |
669 | - buf.readBytes(testupdateMsg, 0, iReadLen); | ||
670 | - | ||
671 | - if (Arrays.equals(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) { | 602 | + |
708 | - e.printStackTrace(); | 603 | + Assert.assertTrue("PcepMessage is not instance of PcepUpdateMsg", message instanceof PcepUpdateMsg); |
709 | - } | 604 | + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); |
710 | - | 605 | + message.writeTo(buf); |
711 | - if (message instanceof PcepUpdateMsg) { | 606 | + testupdateMsg = buf.array(); |
712 | - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); | 607 | + |
713 | - message.writeTo(buf); | 608 | + int readLen = buf.writerIndex() - 0; |
714 | - testupdateMsg = buf.array(); | 609 | + testupdateMsg = new byte[readLen]; |
715 | - | 610 | + buf.readBytes(testupdateMsg, 0, readLen); |
716 | - int iReadLen = buf.writerIndex() - 0; | 611 | + |
717 | - testupdateMsg = new byte[iReadLen]; | 612 | + Assert.assertArrayEquals("PcepUpdatemsg messages are not equal", updateMsg, testupdateMsg); |
718 | - buf.readBytes(testupdateMsg, 0, iReadLen); | ||
719 | - | ||
720 | - if (Arrays.equals(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) { | 641 | + |
754 | - e.printStackTrace(); | 642 | + Assert.assertTrue("PcepMessage is not instance of PcepUpdateMsg", message instanceof PcepUpdateMsg); |
755 | - } | 643 | + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); |
756 | - | 644 | + message.writeTo(buf); |
757 | - if (message instanceof PcepUpdateMsg) { | 645 | + testupdateMsg = buf.array(); |
758 | - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); | 646 | + |
759 | - message.writeTo(buf); | 647 | + int readLen = buf.writerIndex() - 0; |
760 | - testupdateMsg = buf.array(); | 648 | + testupdateMsg = new byte[readLen]; |
761 | - | 649 | + buf.readBytes(testupdateMsg, 0, readLen); |
762 | - int iReadLen = buf.writerIndex() - 0; | 650 | + |
763 | - testupdateMsg = new byte[iReadLen]; | 651 | + Assert.assertArrayEquals("PcepUpdatemsg messages are not equal", updateMsg, testupdateMsg); |
764 | - buf.readBytes(testupdateMsg, 0, iReadLen); | ||
765 | - | ||
766 | - if (Arrays.equals(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) { | 681 | + |
801 | - e.printStackTrace(); | 682 | + Assert.assertTrue("PcepMessage is not instance of PcepUpdateMsg", message instanceof PcepUpdateMsg); |
802 | - } | 683 | + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); |
803 | - | 684 | + message.writeTo(buf); |
804 | - if (message instanceof PcepUpdateMsg) { | 685 | + testupdateMsg = buf.array(); |
805 | - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); | 686 | + |
806 | - message.writeTo(buf); | 687 | + int readLen = buf.writerIndex() - 0; |
807 | - testupdateMsg = buf.array(); | 688 | + testupdateMsg = new byte[readLen]; |
808 | - | 689 | + buf.readBytes(testupdateMsg, 0, readLen); |
809 | - int iReadLen = buf.writerIndex() - 0; | 690 | + |
810 | - testupdateMsg = new byte[iReadLen]; | 691 | + Assert.assertArrayEquals("PcepUpdatemsg messages are not equal", updateMsg, testupdateMsg); |
811 | - buf.readBytes(testupdateMsg, 0, iReadLen); | ||
812 | - | ||
813 | - if (Arrays.equals(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) { | 722 | + |
849 | - e.printStackTrace(); | 723 | + Assert.assertTrue("PcepMessage is not instance of PcepUpdateMsg", message instanceof PcepUpdateMsg); |
850 | - } | 724 | + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); |
851 | - | 725 | + message.writeTo(buf); |
852 | - if (message instanceof PcepUpdateMsg) { | 726 | + testupdateMsg = buf.array(); |
853 | - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); | 727 | + |
854 | - message.writeTo(buf); | 728 | + int readLen = buf.writerIndex() - 0; |
855 | - testupdateMsg = buf.array(); | 729 | + testupdateMsg = new byte[readLen]; |
856 | - | 730 | + buf.readBytes(testupdateMsg, 0, readLen); |
857 | - int iReadLen = buf.writerIndex() - 0; | 731 | + |
858 | - testupdateMsg = new byte[iReadLen]; | 732 | + Assert.assertArrayEquals("PcepUpdatemsg messages are not equal", updateMsg, testupdateMsg); |
859 | - buf.readBytes(testupdateMsg, 0, iReadLen); | ||
860 | - | ||
861 | - if (Arrays.equals(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) { | 762 | + |
896 | - e.printStackTrace(); | 763 | + Assert.assertTrue("PcepMessage is not instance of PcepUpdateMsg", message instanceof PcepUpdateMsg); |
897 | - } | 764 | + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); |
898 | - | 765 | + message.writeTo(buf); |
899 | - if (message instanceof PcepUpdateMsg) { | 766 | + testupdateMsg = buf.array(); |
900 | - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); | 767 | + |
901 | - message.writeTo(buf); | 768 | + int readLen = buf.writerIndex() - 0; |
902 | - testupdateMsg = buf.array(); | 769 | + testupdateMsg = new byte[readLen]; |
903 | - | 770 | + buf.readBytes(testupdateMsg, 0, readLen); |
904 | - int iReadLen = buf.writerIndex() - 0; | 771 | + |
905 | - testupdateMsg = new byte[iReadLen]; | 772 | + Assert.assertArrayEquals("PcepUpdatemsg messages are not equal", updateMsg, testupdateMsg); |
906 | - buf.readBytes(testupdateMsg, 0, iReadLen); | ||
907 | - | ||
908 | - if (Arrays.equals(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) { | 803 | + |
944 | - e.printStackTrace(); | 804 | + Assert.assertTrue("PcepMessage is not instance of PcepUpdateMsg", message instanceof PcepUpdateMsg); |
945 | - } | 805 | + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); |
946 | - | 806 | + message.writeTo(buf); |
947 | - if (message instanceof PcepUpdateMsg) { | 807 | + testupdateMsg = buf.array(); |
948 | - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); | 808 | + |
949 | - message.writeTo(buf); | 809 | + int readLen = buf.writerIndex() - 0; |
950 | - testupdateMsg = buf.array(); | 810 | + testupdateMsg = new byte[readLen]; |
951 | - | 811 | + buf.readBytes(testupdateMsg, 0, readLen); |
952 | - int iReadLen = buf.writerIndex() - 0; | 812 | + |
953 | - testupdateMsg = new byte[iReadLen]; | 813 | + Assert.assertArrayEquals("PcepUpdatemsg messages are not equal", updateMsg, testupdateMsg); |
954 | - buf.readBytes(testupdateMsg, 0, iReadLen); | ||
955 | - | ||
956 | - if (Arrays.equals(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) { | 844 | + |
992 | - e.printStackTrace(); | 845 | + Assert.assertTrue("PcepMessage is not instance of PcepUpdateMsg", message instanceof PcepUpdateMsg); |
993 | - } | 846 | + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); |
994 | - | 847 | + message.writeTo(buf); |
995 | - if (message instanceof PcepUpdateMsg) { | 848 | + testupdateMsg = buf.array(); |
996 | - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); | 849 | + |
997 | - message.writeTo(buf); | 850 | + int readLen = buf.writerIndex() - 0; |
998 | - testupdateMsg = buf.array(); | 851 | + testupdateMsg = new byte[readLen]; |
999 | - | 852 | + buf.readBytes(testupdateMsg, 0, readLen); |
1000 | - int iReadLen = buf.writerIndex() - 0; | 853 | + |
1001 | - testupdateMsg = new byte[iReadLen]; | 854 | + Assert.assertArrayEquals("PcepUpdatemsg messages are not equal", updateMsg, testupdateMsg); |
1002 | - buf.readBytes(testupdateMsg, 0, iReadLen); | ||
1003 | - | ||
1004 | - if (Arrays.equals(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) { | 882 | + |
1037 | - e.printStackTrace(); | 883 | + Assert.assertTrue("PcepMessage is not instance of PcepUpdateMsg", message instanceof PcepUpdateMsg); |
1038 | - } | 884 | + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); |
1039 | - | 885 | + message.writeTo(buf); |
1040 | - if (message instanceof PcepUpdateMsg) { | 886 | + testupdateMsg = buf.array(); |
1041 | - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); | 887 | + |
1042 | - message.writeTo(buf); | 888 | + int readLen = buf.writerIndex() - 0; |
1043 | - testupdateMsg = buf.array(); | 889 | + testupdateMsg = new byte[readLen]; |
1044 | - | 890 | + buf.readBytes(testupdateMsg, 0, readLen); |
1045 | - int iReadLen = buf.writerIndex() - 0; | 891 | + |
1046 | - testupdateMsg = new byte[iReadLen]; | 892 | + Assert.assertArrayEquals("PcepUpdatemsg messages are not equal", updateMsg, testupdateMsg); |
1047 | - buf.readBytes(testupdateMsg, 0, iReadLen); | ||
1048 | - | ||
1049 | - if (Arrays.equals(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) { | 921 | + |
1083 | - e.printStackTrace(); | 922 | + Assert.assertTrue("PcepMessage is not instance of PcepUpdateMsg", message instanceof PcepUpdateMsg); |
1084 | - } | 923 | + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); |
1085 | - | 924 | + message.writeTo(buf); |
1086 | - if (message instanceof PcepUpdateMsg) { | 925 | + testupdateMsg = buf.array(); |
1087 | - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); | 926 | + |
1088 | - message.writeTo(buf); | 927 | + int readLen = buf.writerIndex() - 0; |
1089 | - testupdateMsg = buf.array(); | 928 | + testupdateMsg = new byte[readLen]; |
1090 | - | 929 | + buf.readBytes(testupdateMsg, 0, readLen); |
1091 | - int iReadLen = buf.writerIndex() - 0; | 930 | + |
1092 | - testupdateMsg = new byte[iReadLen]; | 931 | + Assert.assertArrayEquals("PcepUpdatemsg messages are not equal", updateMsg, testupdateMsg); |
1093 | - buf.readBytes(testupdateMsg, 0, iReadLen); | ||
1094 | - | ||
1095 | - if (Arrays.equals(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) { | 961 | + |
1130 | - e.printStackTrace(); | 962 | + Assert.assertTrue("PcepMessage is not instance of PcepUpdateMsg", message instanceof PcepUpdateMsg); |
1131 | - } | 963 | + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); |
1132 | - | 964 | + message.writeTo(buf); |
1133 | - if (message instanceof PcepUpdateMsg) { | 965 | + testupdateMsg = buf.array(); |
1134 | - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); | 966 | + |
1135 | - message.writeTo(buf); | 967 | + int readLen = buf.writerIndex() - 0; |
1136 | - testupdateMsg = buf.array(); | 968 | + testupdateMsg = new byte[readLen]; |
1137 | - | 969 | + buf.readBytes(testupdateMsg, 0, readLen); |
1138 | - int iReadLen = buf.writerIndex() - 0; | 970 | + |
1139 | - testupdateMsg = new byte[iReadLen]; | 971 | + Assert.assertArrayEquals("PcepUpdatemsg messages are not equal", updateMsg, testupdateMsg); |
1140 | - buf.readBytes(testupdateMsg, 0, iReadLen); | ||
1141 | - | ||
1142 | - if (Arrays.equals(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) { | 1000 | + |
1176 | - e.printStackTrace(); | 1001 | + Assert.assertTrue("PcepMessage is not instance of PcepUpdateMsg", message instanceof PcepUpdateMsg); |
1177 | - } | 1002 | + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); |
1178 | - | 1003 | + message.writeTo(buf); |
1179 | - if (message instanceof PcepUpdateMsg) { | 1004 | + testupdateMsg = buf.array(); |
1180 | - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); | 1005 | + |
1181 | - message.writeTo(buf); | 1006 | + int readLen = buf.writerIndex() - 0; |
1182 | - testupdateMsg = buf.array(); | 1007 | + testupdateMsg = new byte[readLen]; |
1183 | - | 1008 | + buf.readBytes(testupdateMsg, 0, readLen); |
1184 | - int iReadLen = buf.writerIndex() - 0; | 1009 | + |
1185 | - testupdateMsg = new byte[iReadLen]; | 1010 | + Assert.assertArrayEquals("PcepUpdatemsg messages are not equal", updateMsg, testupdateMsg); |
1186 | - buf.readBytes(testupdateMsg, 0, iReadLen); | ||
1187 | - | ||
1188 | - if (Arrays.equals(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) { | 1040 | + |
1223 | - e.printStackTrace(); | 1041 | + Assert.assertTrue("PcepMessage is not instance of PcepUpdateMsg", message instanceof PcepUpdateMsg); |
1224 | - } | 1042 | + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); |
1225 | - | 1043 | + message.writeTo(buf); |
1226 | - if (message instanceof PcepUpdateMsg) { | 1044 | + testupdateMsg = buf.array(); |
1227 | - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); | 1045 | + |
1228 | - message.writeTo(buf); | 1046 | + int readLen = buf.writerIndex() - 0; |
1229 | - testupdateMsg = buf.array(); | 1047 | + testupdateMsg = new byte[readLen]; |
1230 | - | 1048 | + buf.readBytes(testupdateMsg, 0, readLen); |
1231 | - int iReadLen = buf.writerIndex() - 0; | 1049 | + |
1232 | - testupdateMsg = new byte[iReadLen]; | 1050 | + Assert.assertArrayEquals("PcepUpdatemsg messages are not equal", updateMsg, testupdateMsg); |
1233 | - buf.readBytes(testupdateMsg, 0, iReadLen); | ||
1234 | - | ||
1235 | - if (Arrays.equals(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) { | 1081 | + |
1271 | - e.printStackTrace(); | 1082 | + Assert.assertTrue("PcepMessage is not instance of PcepUpdateMsg", message instanceof PcepUpdateMsg); |
1272 | - } | 1083 | + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); |
1273 | - | 1084 | + message.writeTo(buf); |
1274 | - if (message instanceof PcepUpdateMsg) { | 1085 | + testupdateMsg = buf.array(); |
1275 | - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); | 1086 | + |
1276 | - message.writeTo(buf); | 1087 | + int readLen = buf.writerIndex() - 0; |
1277 | - testupdateMsg = buf.array(); | 1088 | + testupdateMsg = new byte[readLen]; |
1278 | - | 1089 | + buf.readBytes(testupdateMsg, 0, readLen); |
1279 | - int iReadLen = buf.writerIndex() - 0; | 1090 | + |
1280 | - testupdateMsg = new byte[iReadLen]; | 1091 | + Assert.assertArrayEquals("PcepUpdatemsg messages are not equal", updateMsg, testupdateMsg); |
1281 | - buf.readBytes(testupdateMsg, 0, iReadLen); | ||
1282 | - | ||
1283 | - if (Arrays.equals(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) { | 1118 | + |
1315 | - e.printStackTrace(); | 1119 | + Assert.assertTrue("PcepMessage is not instance of PcepUpdateMsg", message instanceof PcepUpdateMsg); |
1316 | - } | 1120 | + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); |
1317 | - | 1121 | + message.writeTo(buf); |
1318 | - if (message instanceof PcepUpdateMsg) { | 1122 | + testupdateMsg = buf.array(); |
1319 | - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); | 1123 | + |
1320 | - message.writeTo(buf); | 1124 | + int readLen = buf.writerIndex() - 0; |
1321 | - testupdateMsg = buf.array(); | 1125 | + testupdateMsg = new byte[readLen]; |
1322 | - | 1126 | + buf.readBytes(testupdateMsg, 0, readLen); |
1323 | - int iReadLen = buf.writerIndex() - 0; | 1127 | + |
1324 | - testupdateMsg = new byte[iReadLen]; | 1128 | + Assert.assertArrayEquals("PcepUpdatemsg messages are not equal", updateMsg, testupdateMsg); |
1325 | - buf.readBytes(testupdateMsg, 0, iReadLen); | ||
1326 | - | ||
1327 | - if (Arrays.equals(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) { | 1156 | + |
1360 | - e.printStackTrace(); | 1157 | + Assert.assertTrue("PcepMessage is not instance of PcepUpdateMsg", message instanceof PcepUpdateMsg); |
1361 | - } | 1158 | + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); |
1362 | - | 1159 | + message.writeTo(buf); |
1363 | - if (message instanceof PcepUpdateMsg) { | 1160 | + testupdateMsg = buf.array(); |
1364 | - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); | 1161 | + |
1365 | - message.writeTo(buf); | 1162 | + int readLen = buf.writerIndex() - 0; |
1366 | - testupdateMsg = buf.array(); | 1163 | + testupdateMsg = new byte[readLen]; |
1367 | - | 1164 | + buf.readBytes(testupdateMsg, 0, readLen); |
1368 | - int iReadLen = buf.writerIndex() - 0; | 1165 | + |
1369 | - testupdateMsg = new byte[iReadLen]; | 1166 | + Assert.assertArrayEquals("PcepUpdatemsg messages are not equal", updateMsg, testupdateMsg); |
1370 | - buf.readBytes(testupdateMsg, 0, iReadLen); | ||
1371 | - | ||
1372 | - if (Arrays.equals(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) { | 1197 | + |
1408 | - e.printStackTrace(); | 1198 | + Assert.assertTrue("PcepMessage is not instance of PcepUpdateMsg", message instanceof PcepUpdateMsg); |
1409 | - } | 1199 | + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); |
1410 | - | 1200 | + message.writeTo(buf); |
1411 | - if (message instanceof PcepUpdateMsg) { | 1201 | + testupdateMsg = buf.array(); |
1412 | - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); | 1202 | + |
1413 | - message.writeTo(buf); | 1203 | + int readLen = buf.writerIndex() - 0; |
1414 | - testupdateMsg = buf.array(); | 1204 | + testupdateMsg = new byte[readLen]; |
1415 | - | 1205 | + buf.readBytes(testupdateMsg, 0, readLen); |
1416 | - int iReadLen = buf.writerIndex() - 0; | 1206 | + |
1417 | - testupdateMsg = new byte[iReadLen]; | 1207 | + Assert.assertArrayEquals("PcepUpdatemsg messages are not equal", updateMsg, testupdateMsg); |
1418 | - buf.readBytes(testupdateMsg, 0, iReadLen); | ||
1419 | - | ||
1420 | - if (Arrays.equals(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) { | 1237 | + |
1455 | - e.printStackTrace(); | 1238 | + Assert.assertTrue("PcepMessage is not instance of PcepUpdateMsg", message instanceof PcepUpdateMsg); |
1456 | - } | 1239 | + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); |
1457 | - | 1240 | + message.writeTo(buf); |
1458 | - if (message instanceof PcepUpdateMsg) { | 1241 | + testupdateMsg = buf.array(); |
1459 | - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); | 1242 | + |
1460 | - message.writeTo(buf); | 1243 | + int readLen = buf.writerIndex() - 0; |
1461 | - testupdateMsg = buf.array(); | 1244 | + testupdateMsg = new byte[readLen]; |
1462 | - | 1245 | + buf.readBytes(testupdateMsg, 0, readLen); |
1463 | - int iReadLen = buf.writerIndex() - 0; | 1246 | + |
1464 | - testupdateMsg = new byte[iReadLen]; | 1247 | + Assert.assertArrayEquals("PcepUpdatemsg messages are not equal", updateMsg, testupdateMsg); |
1465 | - buf.readBytes(testupdateMsg, 0, iReadLen); | ||
1466 | - | ||
1467 | - if (Arrays.equals(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) { | 1277 | + |
1502 | - e.printStackTrace(); | 1278 | + Assert.assertTrue("PcepMessage is not instance of PcepUpdateMsg", message instanceof PcepUpdateMsg); |
1503 | - } | 1279 | + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); |
1504 | - | 1280 | + message.writeTo(buf); |
1505 | - if (message instanceof PcepUpdateMsg) { | 1281 | + testupdateMsg = buf.array(); |
1506 | - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); | 1282 | + |
1507 | - message.writeTo(buf); | 1283 | + int readLen = buf.writerIndex() - 0; |
1508 | - testupdateMsg = buf.array(); | 1284 | + testupdateMsg = new byte[readLen]; |
1509 | - | 1285 | + buf.readBytes(testupdateMsg, 0, readLen); |
1510 | - int iReadLen = buf.writerIndex() - 0; | 1286 | + |
1511 | - testupdateMsg = new byte[iReadLen]; | 1287 | + Assert.assertArrayEquals("PcepUpdatemsg messages are not equal", updateMsg, testupdateMsg); |
1512 | - buf.readBytes(testupdateMsg, 0, iReadLen); | ||
1513 | - | ||
1514 | - if (Arrays.equals(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) { | 1319 | + |
1551 | - e.printStackTrace(); | 1320 | + Assert.assertTrue("PcepMessage is not instance of PcepUpdateMsg", message instanceof PcepUpdateMsg); |
1552 | - } | 1321 | + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); |
1553 | - | 1322 | + message.writeTo(buf); |
1554 | - if (message instanceof PcepUpdateMsg) { | 1323 | + testupdateMsg = buf.array(); |
1555 | - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); | 1324 | + |
1556 | - message.writeTo(buf); | 1325 | + int readLen = buf.writerIndex() - 0; |
1557 | - testupdateMsg = buf.array(); | 1326 | + testupdateMsg = new byte[readLen]; |
1558 | - | 1327 | + buf.readBytes(testupdateMsg, 0, readLen); |
1559 | - int iReadLen = buf.writerIndex() - 0; | 1328 | + |
1560 | - testupdateMsg = new byte[iReadLen]; | 1329 | + Assert.assertArrayEquals("PcepUpdatemsg messages are not equal", updateMsg, testupdateMsg); |
1561 | - buf.readBytes(testupdateMsg, 0, iReadLen); | ||
1562 | - | ||
1563 | - if (Arrays.equals(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 | ... | ... |
-
Please register or login to post a comment