Committed by
Gerrit Code Review
UT updated to add javadoc, remove logs and if check
Change-Id: Ie8355c20e0ebb9c5a9136cb3eb98c8b716b61050
Showing
1 changed file
with
165 additions
and
323 deletions
... | @@ -15,42 +15,30 @@ | ... | @@ -15,42 +15,30 @@ |
15 | */ | 15 | */ |
16 | package org.onosproject.pcepio; | 16 | package org.onosproject.pcepio; |
17 | 17 | ||
18 | -import java.util.Arrays; | 18 | +import static org.hamcrest.MatcherAssert.assertThat; |
19 | +import static org.hamcrest.core.Is.is; | ||
20 | +import static org.hamcrest.core.IsSame.sameInstance; | ||
19 | 21 | ||
20 | import org.jboss.netty.buffer.ChannelBuffer; | 22 | import org.jboss.netty.buffer.ChannelBuffer; |
21 | import org.jboss.netty.buffer.ChannelBuffers; | 23 | import org.jboss.netty.buffer.ChannelBuffers; |
22 | -import org.junit.After; | ||
23 | -import org.junit.Assert; | ||
24 | -import org.junit.Before; | ||
25 | import org.junit.Test; | 24 | import org.junit.Test; |
26 | import org.onosproject.pcepio.exceptions.PcepParseException; | 25 | import org.onosproject.pcepio.exceptions.PcepParseException; |
27 | import org.onosproject.pcepio.protocol.PcepFactories; | 26 | import org.onosproject.pcepio.protocol.PcepFactories; |
28 | import org.onosproject.pcepio.protocol.PcepMessage; | 27 | import org.onosproject.pcepio.protocol.PcepMessage; |
29 | import org.onosproject.pcepio.protocol.PcepMessageReader; | 28 | import org.onosproject.pcepio.protocol.PcepMessageReader; |
30 | import org.onosproject.pcepio.protocol.PcepOpenMsg; | 29 | import org.onosproject.pcepio.protocol.PcepOpenMsg; |
31 | -import org.slf4j.Logger; | ||
32 | -import org.slf4j.LoggerFactory; | ||
33 | - | ||
34 | /** | 30 | /** |
35 | * Test cases for PCEP OPEN Message. | 31 | * Test cases for PCEP OPEN Message. |
36 | */ | 32 | */ |
37 | public class PcepOpenMsgTest { | 33 | public class PcepOpenMsgTest { |
38 | 34 | ||
39 | - protected static final Logger log = LoggerFactory.getLogger(PcepOpenMsgTest.class); | 35 | + /** |
40 | - | 36 | + * This test case checks open object with STATEFUL-PCE-CAPABILITY, GMPLS-CAPABILITY-TLV, |
41 | - @Before | 37 | + * PCECC-CAPABILITY-TLV in Pcep Open message. |
42 | - public void startUp() { | 38 | + */ |
43 | - } | ||
44 | - | ||
45 | - @After | ||
46 | - public void tearDown() { | ||
47 | - | ||
48 | - } | ||
49 | - | ||
50 | @Test | 39 | @Test |
51 | public void openMessageTest1() throws PcepParseException { | 40 | public void openMessageTest1() throws PcepParseException { |
52 | 41 | ||
53 | - // OPEN OBJECT (STATEFUL-PCE-CAPABILITY, GMPLS-CAPABILITY-TLV, PCECC-CAPABILITY-TLV, ) | ||
54 | byte[] openMsg = new byte[] {0x20, 0x01, 0x00, 0x24, 0x01, 0x10, 0x00, 0x20, 0x20, 0x1e, 0x78, (byte) 0xbd, | 42 | byte[] openMsg = new byte[] {0x20, 0x01, 0x00, 0x24, 0x01, 0x10, 0x00, 0x20, 0x20, 0x1e, 0x78, (byte) 0xbd, |
55 | 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0x0f, //STATEFUL-PCE-CAPABILITY | 43 | 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0x0f, //STATEFUL-PCE-CAPABILITY |
56 | 0x00, 0x0e, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, //GMPLS-CAPABILITY-TLV | 44 | 0x00, 0x0e, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, //GMPLS-CAPABILITY-TLV |
... | @@ -63,38 +51,28 @@ public class PcepOpenMsgTest { | ... | @@ -63,38 +51,28 @@ public class PcepOpenMsgTest { |
63 | 51 | ||
64 | PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); | 52 | PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); |
65 | PcepMessage message = null; | 53 | PcepMessage message = null; |
66 | - try { | 54 | + |
67 | message = reader.readFrom(buffer); | 55 | message = reader.readFrom(buffer); |
68 | - } catch (PcepParseException e) { | ||
69 | - e.printStackTrace(); | ||
70 | - } | ||
71 | 56 | ||
72 | - if (message instanceof PcepOpenMsg) { | 57 | + assertThat(message, sameInstance((PcepOpenMsg) message)); |
73 | ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); | 58 | ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); |
74 | message.writeTo(buf); | 59 | message.writeTo(buf); |
75 | testOpenMsg = buf.array(); | 60 | testOpenMsg = buf.array(); |
76 | 61 | ||
77 | - int iReadLen = buf.writerIndex() - 0; | 62 | + int readLen = buf.writerIndex() - 0; |
78 | - testOpenMsg = new byte[iReadLen]; | 63 | + testOpenMsg = new byte[readLen]; |
79 | - buf.readBytes(testOpenMsg, 0, iReadLen); | 64 | + buf.readBytes(testOpenMsg, 0, readLen); |
65 | + | ||
66 | + assertThat(testOpenMsg, is(openMsg)); | ||
80 | 67 | ||
81 | - if (Arrays.equals(openMsg, testOpenMsg)) { | ||
82 | - Assert.assertArrayEquals(openMsg, testOpenMsg); | ||
83 | - log.debug("openMsg are equal :" + openMsg); | ||
84 | - } else { | ||
85 | - Assert.fail("test case failed"); | ||
86 | - log.debug("not equal"); | ||
87 | - } | ||
88 | - } else { | ||
89 | - Assert.fail("test case failed"); | ||
90 | - log.debug("not equal"); | ||
91 | - } | ||
92 | } | 68 | } |
93 | 69 | ||
70 | + /** | ||
71 | + * This test case checks open object with STATEFUL-PCE-CAPABILITY-TLV in Pcep Open message. | ||
72 | + */ | ||
94 | @Test | 73 | @Test |
95 | public void openMessageTest2() throws PcepParseException { | 74 | public void openMessageTest2() throws PcepParseException { |
96 | 75 | ||
97 | - // OPEN OBJECT (STATEFUL-PCE-CAPABILITY). | ||
98 | byte[] openMsg = new byte[] {0x20, 0x01, 0x00, 0x14, // common header | 76 | byte[] openMsg = new byte[] {0x20, 0x01, 0x00, 0x14, // common header |
99 | 0x01, 0x10, 0x00, 0x10, // common object header | 77 | 0x01, 0x10, 0x00, 0x10, // common object header |
100 | 0x20, 0x1E, 0x78, 0x01, // OPEN object | 78 | 0x20, 0x1E, 0x78, 0x01, // OPEN object |
... | @@ -105,38 +83,28 @@ public class PcepOpenMsgTest { | ... | @@ -105,38 +83,28 @@ public class PcepOpenMsgTest { |
105 | 83 | ||
106 | PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); | 84 | PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); |
107 | PcepMessage message = null; | 85 | PcepMessage message = null; |
108 | - try { | 86 | + |
109 | message = reader.readFrom(buffer); | 87 | message = reader.readFrom(buffer); |
110 | - } catch (PcepParseException e) { | ||
111 | - e.printStackTrace(); | ||
112 | - } | ||
113 | 88 | ||
114 | - if (message instanceof PcepOpenMsg) { | 89 | + assertThat(message, sameInstance((PcepOpenMsg) message)); |
115 | ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); | 90 | ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); |
116 | message.writeTo(buf); | 91 | message.writeTo(buf); |
117 | testOpenMsg = buf.array(); | 92 | testOpenMsg = buf.array(); |
118 | 93 | ||
119 | - int iReadLen = buf.writerIndex() - 0; | 94 | + int readLen = buf.writerIndex() - 0; |
120 | - testOpenMsg = new byte[iReadLen]; | 95 | + testOpenMsg = new byte[readLen]; |
121 | - buf.readBytes(testOpenMsg, 0, iReadLen); | 96 | + buf.readBytes(testOpenMsg, 0, readLen); |
97 | + | ||
98 | + assertThat(testOpenMsg, is(openMsg)); | ||
122 | 99 | ||
123 | - if (Arrays.equals(openMsg, testOpenMsg)) { | ||
124 | - Assert.assertArrayEquals(openMsg, testOpenMsg); | ||
125 | - log.debug("openMsg are equal :" + openMsg); | ||
126 | - } else { | ||
127 | - Assert.fail("test case failed"); | ||
128 | - log.debug("not equal"); | ||
129 | - } | ||
130 | - } else { | ||
131 | - Assert.fail("test case failed"); | ||
132 | - log.debug("not equal"); | ||
133 | - } | ||
134 | } | 100 | } |
135 | 101 | ||
102 | + /** | ||
103 | + * This test case checks open object with GmplsCapability tlv in Pcep Open message. | ||
104 | + */ | ||
136 | @Test | 105 | @Test |
137 | public void openMessageTest3() throws PcepParseException { | 106 | public void openMessageTest3() throws PcepParseException { |
138 | 107 | ||
139 | - // OPEN OBJECT (GmplsCapability). | ||
140 | byte[] openMsg = new byte[] {0x20, 0x01, 0x00, 0x14, // common header | 108 | byte[] openMsg = new byte[] {0x20, 0x01, 0x00, 0x14, // common header |
141 | 0x01, 0x10, 0x00, 0x10, // common object header | 109 | 0x01, 0x10, 0x00, 0x10, // common object header |
142 | 0x20, 0x1E, 0x78, 0x01, // OPEN object | 110 | 0x20, 0x1E, 0x78, 0x01, // OPEN object |
... | @@ -148,38 +116,29 @@ public class PcepOpenMsgTest { | ... | @@ -148,38 +116,29 @@ public class PcepOpenMsgTest { |
148 | 116 | ||
149 | PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); | 117 | PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); |
150 | PcepMessage message = null; | 118 | PcepMessage message = null; |
151 | - try { | 119 | + |
152 | message = reader.readFrom(buffer); | 120 | message = reader.readFrom(buffer); |
153 | - } catch (PcepParseException e) { | ||
154 | - e.printStackTrace(); | ||
155 | - } | ||
156 | 121 | ||
157 | - if (message instanceof PcepOpenMsg) { | 122 | + assertThat(message, sameInstance((PcepOpenMsg) message)); |
158 | ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); | 123 | ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); |
159 | message.writeTo(buf); | 124 | message.writeTo(buf); |
160 | testOpenMsg = buf.array(); | 125 | testOpenMsg = buf.array(); |
161 | 126 | ||
162 | - int iReadLen = buf.writerIndex() - 0; | 127 | + int readLen = buf.writerIndex() - 0; |
163 | - testOpenMsg = new byte[iReadLen]; | 128 | + testOpenMsg = new byte[readLen]; |
164 | - buf.readBytes(testOpenMsg, 0, iReadLen); | 129 | + buf.readBytes(testOpenMsg, 0, readLen); |
130 | + | ||
131 | + | ||
132 | + assertThat(testOpenMsg, is(openMsg)); | ||
165 | 133 | ||
166 | - if (Arrays.equals(openMsg, testOpenMsg)) { | ||
167 | - Assert.assertArrayEquals(openMsg, testOpenMsg); | ||
168 | - log.debug("openMsg are equal :" + openMsg); | ||
169 | - } else { | ||
170 | - Assert.fail("test case failed"); | ||
171 | - log.debug("not equal"); | ||
172 | - } | ||
173 | - } else { | ||
174 | - Assert.fail("test case failed"); | ||
175 | - log.debug("not equal"); | ||
176 | - } | ||
177 | } | 134 | } |
178 | 135 | ||
136 | + /** | ||
137 | + * This test case checks open object with StatefulLspDbVer Tlv in Pcep Open message. | ||
138 | + */ | ||
179 | @Test | 139 | @Test |
180 | public void openMessageTest4() throws PcepParseException { | 140 | public void openMessageTest4() throws PcepParseException { |
181 | 141 | ||
182 | - // OPEN OBJECT (StatefulLspDbVerTlv). | ||
183 | byte[] openMsg = new byte[] {0x20, 0x01, 0x00, 0x18, | 142 | byte[] openMsg = new byte[] {0x20, 0x01, 0x00, 0x18, |
184 | 0x01, 0x10, 0x00, 0x14, 0x20, 0x1e, 0x78, 0x20, | 143 | 0x01, 0x10, 0x00, 0x14, 0x20, 0x1e, 0x78, 0x20, |
185 | 0x00, 0x17, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02 }; //StatefulLspDbVerTlv | 144 | 0x00, 0x17, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02 }; //StatefulLspDbVerTlv |
... | @@ -190,38 +149,28 @@ public class PcepOpenMsgTest { | ... | @@ -190,38 +149,28 @@ public class PcepOpenMsgTest { |
190 | 149 | ||
191 | PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); | 150 | PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); |
192 | PcepMessage message = null; | 151 | PcepMessage message = null; |
193 | - try { | 152 | + |
194 | message = reader.readFrom(buffer); | 153 | message = reader.readFrom(buffer); |
195 | - } catch (PcepParseException e) { | ||
196 | - e.printStackTrace(); | ||
197 | - } | ||
198 | 154 | ||
199 | - if (message instanceof PcepOpenMsg) { | 155 | + assertThat(message, sameInstance((PcepOpenMsg) message)); |
200 | ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); | 156 | ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); |
201 | message.writeTo(buf); | 157 | message.writeTo(buf); |
202 | testOpenMsg = buf.array(); | 158 | testOpenMsg = buf.array(); |
203 | 159 | ||
204 | - int iReadLen = buf.writerIndex() - 0; | 160 | + int readLen = buf.writerIndex() - 0; |
205 | - testOpenMsg = new byte[iReadLen]; | 161 | + testOpenMsg = new byte[readLen]; |
206 | - buf.readBytes(testOpenMsg, 0, iReadLen); | 162 | + buf.readBytes(testOpenMsg, 0, readLen); |
163 | + | ||
164 | + assertThat(testOpenMsg, is(openMsg)); | ||
207 | 165 | ||
208 | - if (Arrays.equals(openMsg, testOpenMsg)) { | ||
209 | - Assert.assertArrayEquals(openMsg, testOpenMsg); | ||
210 | - log.debug("openMsg are equal :" + openMsg); | ||
211 | - } else { | ||
212 | - Assert.fail("test case failed"); | ||
213 | - log.debug("not equal"); | ||
214 | - } | ||
215 | - } else { | ||
216 | - Assert.fail("test case failed"); | ||
217 | - log.debug("not equal"); | ||
218 | - } | ||
219 | } | 166 | } |
220 | 167 | ||
168 | + /** | ||
169 | + * This test case checks open object with no tlv's in Pcep Open message. | ||
170 | + */ | ||
221 | @Test | 171 | @Test |
222 | public void openMessageTest5() throws PcepParseException { | 172 | public void openMessageTest5() throws PcepParseException { |
223 | 173 | ||
224 | - // OPEN OBJECT (no Tlvs). | ||
225 | byte[] openMsg = new byte[] {0x20, 0x01, 0x00, 0x0C, | 174 | byte[] openMsg = new byte[] {0x20, 0x01, 0x00, 0x0C, |
226 | 0x01, 0x10, 0x00, 0x08, 0x20, 0x1e, 0x78, (byte) 0xbd }; // no Tlvs in open messsage | 175 | 0x01, 0x10, 0x00, 0x08, 0x20, 0x1e, 0x78, (byte) 0xbd }; // no Tlvs in open messsage |
227 | 176 | ||
... | @@ -231,40 +180,29 @@ public class PcepOpenMsgTest { | ... | @@ -231,40 +180,29 @@ public class PcepOpenMsgTest { |
231 | 180 | ||
232 | PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); | 181 | PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); |
233 | PcepMessage message = null; | 182 | PcepMessage message = null; |
234 | - try { | 183 | + |
235 | message = reader.readFrom(buffer); | 184 | message = reader.readFrom(buffer); |
236 | - } catch (PcepParseException e) { | ||
237 | - e.printStackTrace(); | ||
238 | - } | ||
239 | 185 | ||
240 | - if (message instanceof PcepOpenMsg) { | 186 | + assertThat(message, sameInstance((PcepOpenMsg) message)); |
241 | ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); | 187 | ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); |
242 | message.writeTo(buf); | 188 | message.writeTo(buf); |
243 | testOpenMsg = buf.array(); | 189 | testOpenMsg = buf.array(); |
244 | 190 | ||
245 | - int iReadLen = buf.writerIndex() - 0; | 191 | + int readLen = buf.writerIndex() - 0; |
246 | - testOpenMsg = new byte[iReadLen]; | 192 | + testOpenMsg = new byte[readLen]; |
247 | - buf.readBytes(testOpenMsg, 0, iReadLen); | 193 | + buf.readBytes(testOpenMsg, 0, readLen); |
194 | + | ||
195 | + assertThat(testOpenMsg, is(openMsg)); | ||
248 | 196 | ||
249 | - if (Arrays.equals(openMsg, testOpenMsg)) { | ||
250 | - Assert.assertArrayEquals(openMsg, testOpenMsg); | ||
251 | - log.debug("openMsg are equal :" + openMsg); | ||
252 | - } else { | ||
253 | - Assert.fail("test case failed"); | ||
254 | - log.debug("not equal"); | ||
255 | - } | ||
256 | - } else { | ||
257 | - Assert.fail("test case failed"); | ||
258 | - log.debug("not equal"); | ||
259 | - } | ||
260 | } | 197 | } |
261 | 198 | ||
199 | + /** | ||
200 | + * This test case checks open object with STATEFUL-PCE-CAPABILITY, GMPLS-CAPABILITY-TLV, PCECC-CAPABILITY-TLV | ||
201 | + * with I bit set in Pcep Open message. | ||
202 | + */ | ||
262 | @Test | 203 | @Test |
263 | public void openMessageTest6() throws PcepParseException { | 204 | public void openMessageTest6() throws PcepParseException { |
264 | 205 | ||
265 | - /* OPEN OBJECT (STATEFUL-PCE-CAPABILITY, GMPLS-CAPABILITY-TLV, PCECC-CAPABILITY-TLV) with | ||
266 | - p bit not set & i bit set. | ||
267 | - */ | ||
268 | byte[] openMsg = new byte[] {0x20, 0x01, 0x00, 0x24, 0x01, 0x11, 0x00, 0x20, //p bit not set & i bit set | 206 | byte[] openMsg = new byte[] {0x20, 0x01, 0x00, 0x24, 0x01, 0x11, 0x00, 0x20, //p bit not set & i bit set |
269 | 0x20, 0x1e, 0x78, (byte) 0xbd, | 207 | 0x20, 0x1e, 0x78, (byte) 0xbd, |
270 | 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0x0f, // STATEFUL-PCE-CAPABILITY | 208 | 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0x0f, // STATEFUL-PCE-CAPABILITY |
... | @@ -278,40 +216,29 @@ public class PcepOpenMsgTest { | ... | @@ -278,40 +216,29 @@ public class PcepOpenMsgTest { |
278 | 216 | ||
279 | PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); | 217 | PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); |
280 | PcepMessage message = null; | 218 | PcepMessage message = null; |
281 | - try { | 219 | + |
282 | message = reader.readFrom(buffer); | 220 | message = reader.readFrom(buffer); |
283 | - } catch (PcepParseException e) { | ||
284 | - e.printStackTrace(); | ||
285 | - } | ||
286 | 221 | ||
287 | - if (message instanceof PcepOpenMsg) { | 222 | + assertThat(message, sameInstance((PcepOpenMsg) message)); |
288 | ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); | 223 | ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); |
289 | message.writeTo(buf); | 224 | message.writeTo(buf); |
290 | testOpenMsg = buf.array(); | 225 | testOpenMsg = buf.array(); |
291 | 226 | ||
292 | - int iReadLen = buf.writerIndex() - 0; | 227 | + int readLen = buf.writerIndex() - 0; |
293 | - testOpenMsg = new byte[iReadLen]; | 228 | + testOpenMsg = new byte[readLen]; |
294 | - buf.readBytes(testOpenMsg, 0, iReadLen); | 229 | + buf.readBytes(testOpenMsg, 0, readLen); |
230 | + | ||
231 | + assertThat(testOpenMsg, is(openMsg)); | ||
295 | 232 | ||
296 | - if (Arrays.equals(openMsg, testOpenMsg)) { | ||
297 | - Assert.assertArrayEquals(openMsg, testOpenMsg); | ||
298 | - log.debug("openMsg are equal :" + openMsg); | ||
299 | - } else { | ||
300 | - Assert.fail("test case failed"); | ||
301 | - log.debug("not equal"); | ||
302 | - } | ||
303 | - } else { | ||
304 | - Assert.fail("test case failed"); | ||
305 | - log.debug("not equal"); | ||
306 | - } | ||
307 | } | 233 | } |
308 | 234 | ||
235 | + /** | ||
236 | + * This test case checks open object with STATEFUL-PCE-CAPABILITY, GMPLS-CAPABILITY-TLV, PCECC-CAPABILITY-TLV | ||
237 | + * with P bit set in Pcep Open message. | ||
238 | + */ | ||
309 | @Test | 239 | @Test |
310 | public void openMessageTest7() throws PcepParseException { | 240 | public void openMessageTest7() throws PcepParseException { |
311 | 241 | ||
312 | - /* OPEN OBJECT (STATEFUL-PCE-CAPABILITY, GMPLS-CAPABILITY-TLV, PCECC-CAPABILITY-TLV) | ||
313 | - with p bit set & i bit not set. | ||
314 | - */ | ||
315 | byte[] openMsg = new byte[] {0x20, 0x01, 0x00, 0x24, 0x01, 0x12, 0x00, 0x20, //p bit set & i bit not set | 242 | byte[] openMsg = new byte[] {0x20, 0x01, 0x00, 0x24, 0x01, 0x12, 0x00, 0x20, //p bit set & i bit not set |
316 | 0x20, 0x1e, 0x78, (byte) 0xbd, | 243 | 0x20, 0x1e, 0x78, (byte) 0xbd, |
317 | 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0x0f, //STATEFUL-PCE-CAPABILITY | 244 | 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0x0f, //STATEFUL-PCE-CAPABILITY |
... | @@ -325,34 +252,26 @@ public class PcepOpenMsgTest { | ... | @@ -325,34 +252,26 @@ public class PcepOpenMsgTest { |
325 | 252 | ||
326 | PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); | 253 | PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); |
327 | PcepMessage message = null; | 254 | PcepMessage message = null; |
328 | - try { | 255 | + |
329 | message = reader.readFrom(buffer); | 256 | message = reader.readFrom(buffer); |
330 | - } catch (PcepParseException e) { | ||
331 | - e.printStackTrace(); | ||
332 | - } | ||
333 | 257 | ||
334 | - if (message instanceof PcepOpenMsg) { | 258 | + assertThat(message, sameInstance((PcepOpenMsg) message)); |
335 | ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); | 259 | ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); |
336 | message.writeTo(buf); | 260 | message.writeTo(buf); |
337 | testOpenMsg = buf.array(); | 261 | testOpenMsg = buf.array(); |
338 | 262 | ||
339 | - int iReadLen = buf.writerIndex() - 0; | 263 | + int readLen = buf.writerIndex() - 0; |
340 | - testOpenMsg = new byte[iReadLen]; | 264 | + testOpenMsg = new byte[readLen]; |
341 | - buf.readBytes(testOpenMsg, 0, iReadLen); | 265 | + buf.readBytes(testOpenMsg, 0, readLen); |
266 | + | ||
267 | + assertThat(testOpenMsg, is(openMsg)); | ||
342 | 268 | ||
343 | - if (Arrays.equals(openMsg, testOpenMsg)) { | ||
344 | - Assert.assertArrayEquals(openMsg, testOpenMsg); | ||
345 | - log.debug("openMsg are equal :" + openMsg); | ||
346 | - } else { | ||
347 | - Assert.fail("test case failed"); | ||
348 | - log.debug("not equal"); | ||
349 | - } | ||
350 | - } else { | ||
351 | - Assert.fail("test case failed"); | ||
352 | - log.debug("not equal"); | ||
353 | - } | ||
354 | } | 269 | } |
355 | 270 | ||
271 | + /** | ||
272 | + * This test case checks open object with STATEFUL-PCE-CAPABILITY, GMPLS-CAPABILITY-TLV, PCECC-CAPABILITY-TLV | ||
273 | + * with P & I bits set in Pcep Open message. | ||
274 | + */ | ||
356 | @Test | 275 | @Test |
357 | public void openMessageTest8() throws PcepParseException { | 276 | public void openMessageTest8() throws PcepParseException { |
358 | 277 | ||
... | @@ -372,40 +291,29 @@ public class PcepOpenMsgTest { | ... | @@ -372,40 +291,29 @@ public class PcepOpenMsgTest { |
372 | 291 | ||
373 | PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); | 292 | PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); |
374 | PcepMessage message = null; | 293 | PcepMessage message = null; |
375 | - try { | 294 | + |
376 | message = reader.readFrom(buffer); | 295 | message = reader.readFrom(buffer); |
377 | - } catch (PcepParseException e) { | ||
378 | - e.printStackTrace(); | ||
379 | - } | ||
380 | 296 | ||
381 | - if (message instanceof PcepOpenMsg) { | 297 | + assertThat(message, sameInstance((PcepOpenMsg) message)); |
382 | ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); | 298 | ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); |
383 | message.writeTo(buf); | 299 | message.writeTo(buf); |
384 | testOpenMsg = buf.array(); | 300 | testOpenMsg = buf.array(); |
385 | 301 | ||
386 | - int iReadLen = buf.writerIndex() - 0; | 302 | + int readLen = buf.writerIndex() - 0; |
387 | - testOpenMsg = new byte[iReadLen]; | 303 | + testOpenMsg = new byte[readLen]; |
388 | - buf.readBytes(testOpenMsg, 0, iReadLen); | 304 | + buf.readBytes(testOpenMsg, 0, readLen); |
305 | + | ||
306 | + assertThat(testOpenMsg, is(openMsg)); | ||
389 | 307 | ||
390 | - if (Arrays.equals(openMsg, testOpenMsg)) { | ||
391 | - Assert.assertArrayEquals(openMsg, testOpenMsg); | ||
392 | - log.debug("openMsg are equal :" + openMsg); | ||
393 | - } else { | ||
394 | - Assert.fail("test case failed"); | ||
395 | - log.debug("not equal"); | ||
396 | - } | ||
397 | - } else { | ||
398 | - Assert.fail("test case failed"); | ||
399 | - log.debug("not equal"); | ||
400 | - } | ||
401 | } | 308 | } |
402 | 309 | ||
310 | + /** | ||
311 | + * This test case checks open object with STATEFUL-PCE-CAPABILITY, GMPLS-CAPABILITY-TLV, PCECC-CAPABILITY-TLV | ||
312 | + * with P & I bits set and invalid session id in Pcep Open message. | ||
313 | + */ | ||
403 | @Test | 314 | @Test |
404 | public void openMessageTest9() throws PcepParseException { | 315 | public void openMessageTest9() throws PcepParseException { |
405 | 316 | ||
406 | - /* OPEN OBJECT (STATEFUL-PCE-CAPABILITY, GMPLS-CAPABILITY-TLV, PCECC-CAPABILITY-TLV) | ||
407 | - with p bit set & i bit set. | ||
408 | - */ | ||
409 | byte[] openMsg = new byte[] {0x20, 0x01, 0x00, 0x24, 0x01, 0x13, 0x00, 0x20, //p bit set & i bit set | 317 | byte[] openMsg = new byte[] {0x20, 0x01, 0x00, 0x24, 0x01, 0x13, 0x00, 0x20, //p bit set & i bit set |
410 | 0x20, 0x1e, 0x78, 0x00, //invalid sessionID | 318 | 0x20, 0x1e, 0x78, 0x00, //invalid sessionID |
411 | 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0x0f, //STATEFUL-PCE-CAPABILITY | 319 | 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0x0f, //STATEFUL-PCE-CAPABILITY |
... | @@ -419,38 +327,30 @@ public class PcepOpenMsgTest { | ... | @@ -419,38 +327,30 @@ public class PcepOpenMsgTest { |
419 | 327 | ||
420 | PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); | 328 | PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); |
421 | PcepMessage message = null; | 329 | PcepMessage message = null; |
422 | - try { | 330 | + |
423 | message = reader.readFrom(buffer); | 331 | message = reader.readFrom(buffer); |
424 | - } catch (PcepParseException e) { | ||
425 | - e.printStackTrace(); | ||
426 | - } | ||
427 | 332 | ||
428 | - if (message instanceof PcepOpenMsg) { | 333 | + assertThat(message, sameInstance((PcepOpenMsg) message)); |
429 | ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); | 334 | ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); |
430 | message.writeTo(buf); | 335 | message.writeTo(buf); |
431 | testOpenMsg = buf.array(); | 336 | testOpenMsg = buf.array(); |
432 | 337 | ||
433 | - int iReadLen = buf.writerIndex() - 0; | 338 | + int readLen = buf.writerIndex() - 0; |
434 | - testOpenMsg = new byte[iReadLen]; | 339 | + testOpenMsg = new byte[readLen]; |
435 | - buf.readBytes(testOpenMsg, 0, iReadLen); | 340 | + buf.readBytes(testOpenMsg, 0, readLen); |
341 | + | ||
342 | + | ||
343 | + assertThat(testOpenMsg, is(openMsg)); | ||
436 | 344 | ||
437 | - if (Arrays.equals(openMsg, testOpenMsg)) { | ||
438 | - Assert.assertArrayEquals(openMsg, testOpenMsg); | ||
439 | - log.debug("openMsg are equal :" + openMsg); | ||
440 | - } else { | ||
441 | - Assert.fail("test case failed"); | ||
442 | - log.debug("not equal"); | ||
443 | - } | ||
444 | - } else { | ||
445 | - Assert.fail("test case failed"); | ||
446 | - log.debug("not equal"); | ||
447 | - } | ||
448 | } | 345 | } |
449 | 346 | ||
347 | + /** | ||
348 | + * This test case checks open object with STATEFUL-PCE-CAPABILITY, GMPLS-CAPABILITY-TLV | ||
349 | + * in Pcep Open message. | ||
350 | + */ | ||
450 | @Test | 351 | @Test |
451 | public void openMessageTest10() throws PcepParseException { | 352 | public void openMessageTest10() throws PcepParseException { |
452 | 353 | ||
453 | - //OPEN OBJECT (STATEFUL-PCE-CAPABILITY, GMPLS-CAPABILITY-TLV). | ||
454 | byte[] openMsg = new byte[] {0x20, 0x01, 0x00, 0x1C, // common header | 354 | byte[] openMsg = new byte[] {0x20, 0x01, 0x00, 0x1C, // common header |
455 | 0x01, 0x10, 0x00, 0x18, // common object header | 355 | 0x01, 0x10, 0x00, 0x18, // common object header |
456 | 0x20, 0x05, 0x1E, 0x01, // OPEN object | 356 | 0x20, 0x05, 0x1E, 0x01, // OPEN object |
... | @@ -465,38 +365,29 @@ public class PcepOpenMsgTest { | ... | @@ -465,38 +365,29 @@ public class PcepOpenMsgTest { |
465 | 365 | ||
466 | PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); | 366 | PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); |
467 | PcepMessage message = null; | 367 | PcepMessage message = null; |
468 | - try { | 368 | + |
469 | message = reader.readFrom(buffer); | 369 | message = reader.readFrom(buffer); |
470 | - } catch (PcepParseException e) { | ||
471 | - e.printStackTrace(); | ||
472 | - } | ||
473 | 370 | ||
474 | - if (message instanceof PcepOpenMsg) { | 371 | + assertThat(message, sameInstance((PcepOpenMsg) message)); |
475 | ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); | 372 | ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); |
476 | message.writeTo(buf); | 373 | message.writeTo(buf); |
477 | testOpenMsg = buf.array(); | 374 | testOpenMsg = buf.array(); |
478 | 375 | ||
479 | - int iReadLen = buf.writerIndex() - 0; | 376 | + int readLen = buf.writerIndex() - 0; |
480 | - testOpenMsg = new byte[iReadLen]; | 377 | + testOpenMsg = new byte[readLen]; |
481 | - buf.readBytes(testOpenMsg, 0, iReadLen); | 378 | + buf.readBytes(testOpenMsg, 0, readLen); |
379 | + | ||
380 | + assertThat(testOpenMsg, is(openMsg)); | ||
482 | 381 | ||
483 | - if (Arrays.equals(openMsg, testOpenMsg)) { | ||
484 | - Assert.assertArrayEquals(openMsg, testOpenMsg); | ||
485 | - log.debug("openMsg are equal :" + openMsg); | ||
486 | - } else { | ||
487 | - Assert.fail("test case failed"); | ||
488 | - log.debug("not equal"); | ||
489 | - } | ||
490 | - } else { | ||
491 | - Assert.fail("test case failed"); | ||
492 | - log.debug("not equal"); | ||
493 | - } | ||
494 | } | 382 | } |
495 | 383 | ||
384 | + /** | ||
385 | + * This test case checks open object with STATEFUL-PCE-CAPABILITY, GMPLS-CAPABILITY-TLV, | ||
386 | + * PCECC-CAPABILITY-TLV, TED Capability TLV in Pcep Open message. | ||
387 | + */ | ||
496 | @Test | 388 | @Test |
497 | public void openMessageTest11() throws PcepParseException { | 389 | public void openMessageTest11() throws PcepParseException { |
498 | 390 | ||
499 | - //OPEN OBJECT (STATEFUL-PCE-CAPABILITY, GMPLS-CAPABILITY-TLV, PCECC-CAPABILITY-TLV, TED Capability TLV). | ||
500 | byte[] openMsg = new byte[] {0x20, 0x01, 0x00, 0x2C, // common header | 391 | byte[] openMsg = new byte[] {0x20, 0x01, 0x00, 0x2C, // common header |
501 | 0x01, 0x10, 0x00, 0x28, // common object header | 392 | 0x01, 0x10, 0x00, 0x28, // common object header |
502 | 0x20, 0x05, 0x1E, 0x01, // OPEN object | 393 | 0x20, 0x05, 0x1E, 0x01, // OPEN object |
... | @@ -512,38 +403,29 @@ public class PcepOpenMsgTest { | ... | @@ -512,38 +403,29 @@ public class PcepOpenMsgTest { |
512 | 403 | ||
513 | PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); | 404 | PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); |
514 | PcepMessage message = null; | 405 | PcepMessage message = null; |
515 | - try { | 406 | + |
516 | message = reader.readFrom(buffer); | 407 | message = reader.readFrom(buffer); |
517 | - } catch (PcepParseException e) { | ||
518 | - e.printStackTrace(); | ||
519 | - } | ||
520 | 408 | ||
521 | - if (message instanceof PcepOpenMsg) { | 409 | + assertThat(message, sameInstance((PcepOpenMsg) message)); |
522 | ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); | 410 | ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); |
523 | message.writeTo(buf); | 411 | message.writeTo(buf); |
524 | testOpenMsg = buf.array(); | 412 | testOpenMsg = buf.array(); |
525 | 413 | ||
526 | - int iReadLen = buf.writerIndex() - 0; | 414 | + int readLen = buf.writerIndex() - 0; |
527 | - testOpenMsg = new byte[iReadLen]; | 415 | + testOpenMsg = new byte[readLen]; |
528 | - buf.readBytes(testOpenMsg, 0, iReadLen); | 416 | + buf.readBytes(testOpenMsg, 0, readLen); |
417 | + | ||
418 | + assertThat(testOpenMsg, is(openMsg)); | ||
529 | 419 | ||
530 | - if (Arrays.equals(openMsg, testOpenMsg)) { | ||
531 | - Assert.assertArrayEquals(openMsg, testOpenMsg); | ||
532 | - log.debug("openMsg are equal :" + openMsg); | ||
533 | - } else { | ||
534 | - Assert.fail("test case failed"); | ||
535 | - log.debug("not equal"); | ||
536 | - } | ||
537 | - } else { | ||
538 | - Assert.fail("test case failed"); | ||
539 | - log.debug("not equal"); | ||
540 | - } | ||
541 | } | 420 | } |
542 | 421 | ||
422 | + /** | ||
423 | + * This test case checks open object with STATEFUL-PCE-CAPABILITY, GMPLS-CAPABILITY-TLV, | ||
424 | + * PCECC-CAPABILITY-TLV in Pcep Open message. | ||
425 | + */ | ||
543 | @Test | 426 | @Test |
544 | public void openMessageTest12() throws PcepParseException { | 427 | public void openMessageTest12() throws PcepParseException { |
545 | 428 | ||
546 | - //OPEN OBJECT (STATEFUL-PCE-CAPABILITY, GMPLS-CAPABILITY-TLV, PCECC-CAPABILITY-TLV). | ||
547 | byte[] openMsg = new byte[] {0x20, 0x01, 0x00, 0x24, // common header | 429 | byte[] openMsg = new byte[] {0x20, 0x01, 0x00, 0x24, // common header |
548 | 0x01, 0x10, 0x00, 0x20, // common object header | 430 | 0x01, 0x10, 0x00, 0x20, // common object header |
549 | 0x20, 0x05, 0x1E, 0x01, // OPEN object | 431 | 0x20, 0x05, 0x1E, 0x01, // OPEN object |
... | @@ -558,38 +440,29 @@ public class PcepOpenMsgTest { | ... | @@ -558,38 +440,29 @@ public class PcepOpenMsgTest { |
558 | 440 | ||
559 | PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); | 441 | PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); |
560 | PcepMessage message = null; | 442 | PcepMessage message = null; |
561 | - try { | 443 | + |
562 | message = reader.readFrom(buffer); | 444 | message = reader.readFrom(buffer); |
563 | - } catch (PcepParseException e) { | ||
564 | - e.printStackTrace(); | ||
565 | - } | ||
566 | 445 | ||
567 | - if (message instanceof PcepOpenMsg) { | 446 | + assertThat(message, sameInstance((PcepOpenMsg) message)); |
568 | ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); | 447 | ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); |
569 | message.writeTo(buf); | 448 | message.writeTo(buf); |
570 | testOpenMsg = buf.array(); | 449 | testOpenMsg = buf.array(); |
571 | 450 | ||
572 | - int iReadLen = buf.writerIndex() - 0; | 451 | + int readLen = buf.writerIndex() - 0; |
573 | - testOpenMsg = new byte[iReadLen]; | 452 | + testOpenMsg = new byte[readLen]; |
574 | - buf.readBytes(testOpenMsg, 0, iReadLen); | 453 | + buf.readBytes(testOpenMsg, 0, readLen); |
454 | + | ||
455 | + assertThat(testOpenMsg, is(openMsg)); | ||
575 | 456 | ||
576 | - if (Arrays.equals(openMsg, testOpenMsg)) { | ||
577 | - Assert.assertArrayEquals(openMsg, testOpenMsg); | ||
578 | - log.debug("openMsg are equal :" + openMsg); | ||
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 | } | 457 | } |
588 | 458 | ||
459 | + /** | ||
460 | + * This test case checks open object with STATEFUL-PCE-CAPABILITY, GMPLS-CAPABILITY-TLV | ||
461 | + * in Pcep Open message. | ||
462 | + */ | ||
589 | @Test | 463 | @Test |
590 | public void openMessageTest13() throws PcepParseException { | 464 | public void openMessageTest13() throws PcepParseException { |
591 | 465 | ||
592 | - //OPEN OBJECT (STATEFUL-PCE-CAPABILITY, GMPLS-CAPABILITY-TLV). | ||
593 | byte[] openMsg = new byte[] {0x20, 0x01, 0x00, 0x1c, // common header | 466 | byte[] openMsg = new byte[] {0x20, 0x01, 0x00, 0x1c, // common header |
594 | 0x01, 0x10, 0x00, 0x18, // common object header | 467 | 0x01, 0x10, 0x00, 0x18, // common object header |
595 | 0x20, 0x05, 0x1E, 0x01, // OPEN object | 468 | 0x20, 0x05, 0x1E, 0x01, // OPEN object |
... | @@ -603,38 +476,29 @@ public class PcepOpenMsgTest { | ... | @@ -603,38 +476,29 @@ public class PcepOpenMsgTest { |
603 | 476 | ||
604 | PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); | 477 | PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); |
605 | PcepMessage message = null; | 478 | PcepMessage message = null; |
606 | - try { | 479 | + |
607 | message = reader.readFrom(buffer); | 480 | message = reader.readFrom(buffer); |
608 | - } catch (PcepParseException e) { | ||
609 | - e.printStackTrace(); | ||
610 | - } | ||
611 | 481 | ||
612 | - if (message instanceof PcepOpenMsg) { | 482 | + assertThat(message, sameInstance((PcepOpenMsg) message)); |
613 | ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); | 483 | ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); |
614 | message.writeTo(buf); | 484 | message.writeTo(buf); |
615 | testOpenMsg = buf.array(); | 485 | testOpenMsg = buf.array(); |
616 | 486 | ||
617 | - int iReadLen = buf.writerIndex() - 0; | 487 | + int readLen = buf.writerIndex() - 0; |
618 | - testOpenMsg = new byte[iReadLen]; | 488 | + testOpenMsg = new byte[readLen]; |
619 | - buf.readBytes(testOpenMsg, 0, iReadLen); | 489 | + buf.readBytes(testOpenMsg, 0, readLen); |
490 | + | ||
491 | + | ||
492 | + assertThat(testOpenMsg, is(openMsg)); | ||
620 | 493 | ||
621 | - if (Arrays.equals(openMsg, testOpenMsg)) { | ||
622 | - Assert.assertArrayEquals(openMsg, testOpenMsg); | ||
623 | - log.debug("openMsg are equal :" + openMsg); | ||
624 | - } else { | ||
625 | - Assert.fail("test case failed"); | ||
626 | - log.debug("not equal"); | ||
627 | - } | ||
628 | - } else { | ||
629 | - Assert.fail("test case failed "); | ||
630 | - log.debug("not equal"); | ||
631 | - } | ||
632 | } | 494 | } |
633 | 495 | ||
496 | + /** | ||
497 | + * This test case checks open object with STATEFUL-PCE-CAPABILITY in Pcep Open message. | ||
498 | + */ | ||
634 | @Test | 499 | @Test |
635 | public void openMessageTest14() throws PcepParseException { | 500 | public void openMessageTest14() throws PcepParseException { |
636 | 501 | ||
637 | - //OPEN OBJECT (STATEFUL-PCE-CAPABILITY). | ||
638 | byte[] openMsg = new byte[] {0x20, 0x01, 0x00, 0x14, // common header | 502 | byte[] openMsg = new byte[] {0x20, 0x01, 0x00, 0x14, // common header |
639 | 0x01, 0x10, 0x00, 0x10, // common object header | 503 | 0x01, 0x10, 0x00, 0x10, // common object header |
640 | 0x20, 0x05, 0x1E, 0x01, // OPEN object | 504 | 0x20, 0x05, 0x1E, 0x01, // OPEN object |
... | @@ -647,38 +511,28 @@ public class PcepOpenMsgTest { | ... | @@ -647,38 +511,28 @@ public class PcepOpenMsgTest { |
647 | 511 | ||
648 | PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); | 512 | PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); |
649 | PcepMessage message = null; | 513 | PcepMessage message = null; |
650 | - try { | 514 | + |
651 | message = reader.readFrom(buffer); | 515 | message = reader.readFrom(buffer); |
652 | - } catch (PcepParseException e) { | ||
653 | - e.printStackTrace(); | ||
654 | - } | ||
655 | 516 | ||
656 | - if (message instanceof PcepOpenMsg) { | 517 | + assertThat(message, sameInstance((PcepOpenMsg) message)); |
657 | ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); | 518 | ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); |
658 | message.writeTo(buf); | 519 | message.writeTo(buf); |
659 | testOpenMsg = buf.array(); | 520 | testOpenMsg = buf.array(); |
660 | 521 | ||
661 | - int iReadLen = buf.writerIndex() - 0; | 522 | + int readLen = buf.writerIndex() - 0; |
662 | - testOpenMsg = new byte[iReadLen]; | 523 | + testOpenMsg = new byte[readLen]; |
663 | - buf.readBytes(testOpenMsg, 0, iReadLen); | 524 | + buf.readBytes(testOpenMsg, 0, readLen); |
525 | + | ||
526 | + assertThat(testOpenMsg, is(openMsg)); | ||
664 | 527 | ||
665 | - if (Arrays.equals(openMsg, testOpenMsg)) { | ||
666 | - Assert.assertArrayEquals(openMsg, testOpenMsg); | ||
667 | - log.debug("openMsg are equal :" + openMsg); | ||
668 | - } else { | ||
669 | - Assert.fail("test case failed"); | ||
670 | - log.debug("not equal"); | ||
671 | - } | ||
672 | - } else { | ||
673 | - Assert.fail("test case failed"); | ||
674 | - log.debug("not equal"); | ||
675 | - } | ||
676 | } | 528 | } |
677 | 529 | ||
530 | + /** | ||
531 | + * This test case checks open object with no tlv Pcep Open message. | ||
532 | + */ | ||
678 | @Test | 533 | @Test |
679 | public void openMessageTest15() throws PcepParseException { | 534 | public void openMessageTest15() throws PcepParseException { |
680 | 535 | ||
681 | - // OPEN OBJECT. | ||
682 | byte[] openMsg = new byte[] {0x20, 0x01, 0x00, 0x0c, // common header | 536 | byte[] openMsg = new byte[] {0x20, 0x01, 0x00, 0x0c, // common header |
683 | 0x01, 0x10, 0x00, 0x08, // common object header | 537 | 0x01, 0x10, 0x00, 0x08, // common object header |
684 | 0x20, 0x05, 0x1E, 0x01 // OPEN object | 538 | 0x20, 0x05, 0x1E, 0x01 // OPEN object |
... | @@ -690,31 +544,19 @@ public class PcepOpenMsgTest { | ... | @@ -690,31 +544,19 @@ public class PcepOpenMsgTest { |
690 | 544 | ||
691 | PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); | 545 | PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); |
692 | PcepMessage message = null; | 546 | PcepMessage message = null; |
693 | - try { | 547 | + |
694 | message = reader.readFrom(buffer); | 548 | message = reader.readFrom(buffer); |
695 | - } catch (PcepParseException e) { | ||
696 | - e.printStackTrace(); | ||
697 | - } | ||
698 | 549 | ||
699 | - if (message instanceof PcepOpenMsg) { | 550 | + assertThat(message, sameInstance((PcepOpenMsg) message)); |
551 | + | ||
700 | ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); | 552 | ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); |
701 | message.writeTo(buf); | 553 | message.writeTo(buf); |
702 | testOpenMsg = buf.array(); | 554 | testOpenMsg = buf.array(); |
703 | 555 | ||
704 | - int iReadLen = buf.writerIndex() - 0; | 556 | + int readLen = buf.writerIndex() - 0; |
705 | - testOpenMsg = new byte[iReadLen]; | 557 | + testOpenMsg = new byte[readLen]; |
706 | - buf.readBytes(testOpenMsg, 0, iReadLen); | 558 | + buf.readBytes(testOpenMsg, 0, readLen); |
559 | + assertThat(testOpenMsg, is(openMsg)); | ||
707 | 560 | ||
708 | - if (Arrays.equals(openMsg, testOpenMsg)) { | ||
709 | - Assert.assertArrayEquals(openMsg, testOpenMsg); | ||
710 | - log.debug("openMsg are equal :" + openMsg); | ||
711 | - } else { | ||
712 | - Assert.fail("test case failed"); | ||
713 | - log.debug("not equal"); | ||
714 | - } | ||
715 | - } else { | ||
716 | - Assert.fail("test case failed"); | ||
717 | - log.debug("not equal"); | ||
718 | - } | ||
719 | } | 561 | } |
720 | } | 562 | } | ... | ... |
-
Please register or login to post a comment