blob: 4a4956ff7cf7332c88dc316c2025fa6f7626e1ab [file] [log] [blame]
Mahesh Poojary S1c356e32015-08-21 15:05:30 +05301/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2015-present Open Networking Foundation
Mahesh Poojary S1c356e32015-08-21 15:05:30 +05303 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
Sho SHIMIZU3559c312015-11-04 14:59:31 -080016package org.onosproject.pcepio.protocol;
Mahesh Poojary S1c356e32015-08-21 15:05:30 +053017
Mahesh Poojary S1c356e32015-08-21 15:05:30 +053018
19import org.jboss.netty.buffer.ChannelBuffer;
20import org.jboss.netty.buffer.ChannelBuffers;
Mahesh Poojary S1c356e32015-08-21 15:05:30 +053021import org.junit.Test;
Mahesh Poojary Sf1bbd362016-02-25 18:19:59 +053022import org.onosproject.pcepio.exceptions.PcepOutOfBoundMessageException;
Mahesh Poojary S1c356e32015-08-21 15:05:30 +053023import org.onosproject.pcepio.exceptions.PcepParseException;
Mahesh Poojary S1c356e32015-08-21 15:05:30 +053024
Phaneendra Manda75daf942015-08-27 20:10:02 +053025import static org.hamcrest.MatcherAssert.assertThat;
Sho SHIMIZUe090a422015-09-04 17:35:49 -070026import static org.hamcrest.Matchers.instanceOf;
Phaneendra Manda75daf942015-08-27 20:10:02 +053027import static org.hamcrest.core.Is.is;
Phaneendra Manda75daf942015-08-27 20:10:02 +053028
Mahesh Poojary S1c356e32015-08-21 15:05:30 +053029/**
30 * Test cases for PCEP ERROR Message.
31 */
32public class PcepErrorMsgTest {
33
mahesh poojary s87977d12015-08-24 19:15:37 +053034 /**
35 * This test case checks for
36 * PCEP-ERROR Object, OPEN Object (STATEFUL-PCE-CAPABILITY, GMPLS-CAPABILITY-TLV,
Mahesh Poojary Sf1bbd362016-02-25 18:19:59 +053037 * PCECC-CAPABILITY-TLV, LS Capability TLV)
mahesh poojary s87977d12015-08-24 19:15:37 +053038 * in PcepErrorMsg message.
mahesh poojary s87977d12015-08-24 19:15:37 +053039 */
Mahesh Poojary S1c356e32015-08-21 15:05:30 +053040 @Test
Mahesh Poojary Sf1bbd362016-02-25 18:19:59 +053041 public void errorMessageTest1() throws PcepParseException, PcepOutOfBoundMessageException {
Mahesh Poojary S1c356e32015-08-21 15:05:30 +053042
Phaneendra Manda75daf942015-08-27 20:10:02 +053043 byte[] errorMsg = new byte[]{0x20, 0x06, 0x00, 0x34, // common header
Mahesh Poojary S1c356e32015-08-21 15:05:30 +053044 0x0D, 0x10, 0x00, 0x08, // PCERR Object Header
45 0x00, 0x00, 0x01, 0x01, 0x01, 0x10, 0x00, 0x28, // OPEN object header
46 0x20, 0x05, 0x1E, 0x01, // OPEN object
47 0x00, 0x10, 0x00, 0x04, // STATEFUL-PCE-CAPABILITY
48 0x00, 0x00, 0x00, 0x05, 0x00, 0x0E, 0x00, 0x04, // GMPLS-CAPABILITY-TLV
Priyanka B21f4b732016-03-21 20:54:12 +053049 0x00, 0x00, 0x00, 0x00, (byte) 0xff, 0x07, 0x00, 0x04, // PCECC-CAPABILITY-TLV
Mahesh Poojary Sf1bbd362016-02-25 18:19:59 +053050 0x00, 0x00, 0x00, 0x03, (byte) 0xFF, (byte) 0x00, 0x00, 0x04, // LS Capability TLV
Phaneendra Manda75daf942015-08-27 20:10:02 +053051 0x00, 0x00, 0x00, 0x00};
Mahesh Poojary S1c356e32015-08-21 15:05:30 +053052
53 ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
54 buffer.writeBytes(errorMsg);
55
56 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
57 PcepMessage message = null;
Mahesh Poojary S1c356e32015-08-21 15:05:30 +053058
mahesh poojary s87977d12015-08-24 19:15:37 +053059 message = reader.readFrom(buffer);
60
Phaneendra Manda75daf942015-08-27 20:10:02 +053061 byte[] testErrorMsg = {0};
Mahesh Poojary S1c356e32015-08-21 15:05:30 +053062 ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
Phaneendra Manda75daf942015-08-27 20:10:02 +053063
Sho SHIMIZUe090a422015-09-04 17:35:49 -070064 assertThat(message, instanceOf(PcepErrorMsg.class));
mahesh poojary s87977d12015-08-24 19:15:37 +053065 message.writeTo(buf);
Phaneendra Manda75daf942015-08-27 20:10:02 +053066 int iReadLen = buf.writerIndex();
mahesh poojary s87977d12015-08-24 19:15:37 +053067 testErrorMsg = new byte[iReadLen];
68 buf.readBytes(testErrorMsg, 0, iReadLen);
Mahesh Poojary S1c356e32015-08-21 15:05:30 +053069
Phaneendra Manda75daf942015-08-27 20:10:02 +053070 assertThat(testErrorMsg, is(errorMsg));
Mahesh Poojary S1c356e32015-08-21 15:05:30 +053071 }
72
mahesh poojary s87977d12015-08-24 19:15:37 +053073 /**
74 * This test case checks for
75 * PCEP-ERROR Object, PCEP-ERROR Object, OPEN Object (STATEFUL-PCE-CAPABILITY, GMPLS-CAPABILITY-TLV,
Mahesh Poojary Sf1bbd362016-02-25 18:19:59 +053076 * PCECC-CAPABILITY-TLV, LS Capability TLV)
mahesh poojary s87977d12015-08-24 19:15:37 +053077 * in PcepErrorMsg message.
mahesh poojary s87977d12015-08-24 19:15:37 +053078 */
Mahesh Poojary S1c356e32015-08-21 15:05:30 +053079 @Test
Mahesh Poojary Sf1bbd362016-02-25 18:19:59 +053080 public void errorMessageTest2() throws PcepParseException, PcepOutOfBoundMessageException {
Mahesh Poojary S1c356e32015-08-21 15:05:30 +053081
Phaneendra Manda75daf942015-08-27 20:10:02 +053082 byte[] errorMsg = new byte[]{0x20, 0x06, 0x00, 0x3C, // common header
Mahesh Poojary S1c356e32015-08-21 15:05:30 +053083 0x0D, 0x10, 0x00, 0x08, // PCERR Object Header
84 0x00, 0x00, 0x01, 0x01, 0x0D, 0x10, 0x00, 0x08, // PCERR Object Header
85 0x00, 0x00, 0x01, 0x03, 0x01, 0x10, 0x00, 0x28, // OPEN object header
86 0x20, 0x05, 0x1E, 0x01, // OPEN object
87 0x00, 0x10, 0x00, 0x04, // STATEFUL-PCE-CAPABILITY
88 0x00, 0x00, 0x00, 0x05, 0x00, 0x0E, 0x00, 0x04, // GMPLS-CAPABILITY-TLV
Priyanka B21f4b732016-03-21 20:54:12 +053089 0x00, 0x00, 0x00, 0x00, (byte) 0xff, 0x07, 0x00, 0x04, // PCECC-CAPABILITY-TLV
Mahesh Poojary Sf1bbd362016-02-25 18:19:59 +053090 0x00, 0x00, 0x00, 0x03, (byte) 0xFF, (byte) 0x00, 0x00, 0x04, // LS Capability TLV
Phaneendra Manda75daf942015-08-27 20:10:02 +053091 0x00, 0x00, 0x00, 0x00};
Mahesh Poojary S1c356e32015-08-21 15:05:30 +053092
93 ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
94 buffer.writeBytes(errorMsg);
95
96 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
97 PcepMessage message = null;
Mahesh Poojary S1c356e32015-08-21 15:05:30 +053098
mahesh poojary s87977d12015-08-24 19:15:37 +053099 message = reader.readFrom(buffer);
100
Phaneendra Manda75daf942015-08-27 20:10:02 +0530101 byte[] testErrorMsg = {0};
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530102 ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
Sho SHIMIZUe090a422015-09-04 17:35:49 -0700103 assertThat(message, instanceOf(PcepErrorMsg.class));
mahesh poojary s87977d12015-08-24 19:15:37 +0530104 message.writeTo(buf);
Phaneendra Manda75daf942015-08-27 20:10:02 +0530105 int iReadLen = buf.writerIndex();
mahesh poojary s87977d12015-08-24 19:15:37 +0530106 testErrorMsg = new byte[iReadLen];
107 buf.readBytes(testErrorMsg, 0, iReadLen);
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530108
Phaneendra Manda75daf942015-08-27 20:10:02 +0530109 assertThat(testErrorMsg, is(errorMsg));
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530110 }
111
mahesh poojary s87977d12015-08-24 19:15:37 +0530112 /**
113 * This test case checks for
Phaneendra Manda75daf942015-08-27 20:10:02 +0530114 * PCEP-ERROR Object, PCEP-ERROR Object, OPEN Object (STATEFUL-PCE-CAPABILITY, GMPLS-CAPABILITY-TLV,
mahesh poojary s87977d12015-08-24 19:15:37 +0530115 * PCECC-CAPABILITY-TLV)
116 * in PcepErrorMsg message.
mahesh poojary s87977d12015-08-24 19:15:37 +0530117 */
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530118 @Test
Mahesh Poojary Sf1bbd362016-02-25 18:19:59 +0530119 public void errorMessageTest3() throws PcepParseException, PcepOutOfBoundMessageException {
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530120
Phaneendra Manda75daf942015-08-27 20:10:02 +0530121 byte[] errorMsg = new byte[]{0x20, 0x06, 0x00, 0x34, // common header
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530122 0x0D, 0x10, 0x00, 0x08, // PCERR Object Header
123 0x00, 0x00, 0x01, 0x01, 0x0D, 0x10, 0x00, 0x08, // PCERR Object Header
124 0x00, 0x00, 0x01, 0x03, 0x01, 0x10, 0x00, 0x20, // OPEN object header
125 0x20, 0x05, 0x1E, 0x01, // OPEN object
126 0x00, 0x10, 0x00, 0x04, // STATEFUL-PCE-CAPABILITY
127 0x00, 0x00, 0x00, 0x05, 0x00, 0x0E, 0x00, 0x04, // GMPLS-CAPABILITY-TLV
Priyanka B21f4b732016-03-21 20:54:12 +0530128 0x00, 0x00, 0x00, 0x00, (byte) 0xff, 0x07, 0x00, 0x04, // PCECC-CAPABILITY-TLV
Phaneendra Manda75daf942015-08-27 20:10:02 +0530129 0x00, 0x00, 0x00, 0x03};
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530130
131 ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
132 buffer.writeBytes(errorMsg);
133
134 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
135 PcepMessage message = null;
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530136
mahesh poojary s87977d12015-08-24 19:15:37 +0530137 message = reader.readFrom(buffer);
138
Phaneendra Manda75daf942015-08-27 20:10:02 +0530139 byte[] testErrorMsg = {0};
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530140 ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
Sho SHIMIZUe090a422015-09-04 17:35:49 -0700141 assertThat(message, instanceOf(PcepErrorMsg.class));
mahesh poojary s87977d12015-08-24 19:15:37 +0530142 message.writeTo(buf);
Phaneendra Manda75daf942015-08-27 20:10:02 +0530143 int iReadLen = buf.writerIndex();
mahesh poojary s87977d12015-08-24 19:15:37 +0530144 testErrorMsg = new byte[iReadLen];
145 buf.readBytes(testErrorMsg, 0, iReadLen);
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530146
Phaneendra Manda75daf942015-08-27 20:10:02 +0530147 assertThat(testErrorMsg, is(errorMsg));
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530148 }
149
mahesh poojary s87977d12015-08-24 19:15:37 +0530150 /**
151 * This test case checks for
152 * PCEP-ERROR Object, PCEP-ERROR Object, OPEN Object (STATEFUL-PCE-CAPABILITY, GMPLS-CAPABILITY-TLV)
153 * in PcepErrorMsg message.
mahesh poojary s87977d12015-08-24 19:15:37 +0530154 */
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530155 @Test
Mahesh Poojary Sf1bbd362016-02-25 18:19:59 +0530156 public void errorMessageTest4() throws PcepParseException, PcepOutOfBoundMessageException {
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530157
Phaneendra Manda75daf942015-08-27 20:10:02 +0530158 byte[] errorMsg = new byte[]{0x20, 0x06, 0x00, 0x2c, // common header
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530159 0x0D, 0x10, 0x00, 0x08, // PCERR Object Header
160 0x00, 0x00, 0x01, 0x01, 0x0D, 0x10, 0x00, 0x08, // PCERR Object Header
161 0x00, 0x00, 0x01, 0x03, 0x01, 0x10, 0x00, 0x18, // OPEN object header
162 0x20, 0x05, 0x1E, 0x01, // OPEN object
163 0x00, 0x10, 0x00, 0x04, // STATEFUL-PCE-CAPABILITY
164 0x00, 0x00, 0x00, 0x05, 0x00, 0x0E, 0x00, 0x04, // GMPLS-CAPABILITY-TLV
Phaneendra Manda75daf942015-08-27 20:10:02 +0530165 0x00, 0x00, 0x00, 0x00};
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530166
167 ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
168 buffer.writeBytes(errorMsg);
169
170 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
171 PcepMessage message = null;
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530172
mahesh poojary s87977d12015-08-24 19:15:37 +0530173 message = reader.readFrom(buffer);
174
Phaneendra Manda75daf942015-08-27 20:10:02 +0530175 byte[] testErrorMsg = {0};
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530176 ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
Sho SHIMIZUe090a422015-09-04 17:35:49 -0700177 assertThat(message, instanceOf(PcepErrorMsg.class));
mahesh poojary s87977d12015-08-24 19:15:37 +0530178 message.writeTo(buf);
Phaneendra Manda75daf942015-08-27 20:10:02 +0530179 int iReadLen = buf.writerIndex();
mahesh poojary s87977d12015-08-24 19:15:37 +0530180 testErrorMsg = new byte[iReadLen];
181 buf.readBytes(testErrorMsg, 0, iReadLen);
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530182
Phaneendra Manda75daf942015-08-27 20:10:02 +0530183 assertThat(testErrorMsg, is(errorMsg));
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530184 }
185
mahesh poojary s87977d12015-08-24 19:15:37 +0530186 /**
187 * This test case checks for
188 * PCEP-ERROR Object, PCEP-ERROR Object, OPEN Object (STATEFUL-PCE-CAPABILITY)
189 * in PcepErrorMsg message.
mahesh poojary s87977d12015-08-24 19:15:37 +0530190 */
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530191 @Test
Mahesh Poojary Sf1bbd362016-02-25 18:19:59 +0530192 public void errorMessageTest5() throws PcepParseException, PcepOutOfBoundMessageException {
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530193
Phaneendra Manda75daf942015-08-27 20:10:02 +0530194 byte[] errorMsg = new byte[]{0x20, 0x06, 0x00, 0x24, // common header
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530195 0x0D, 0x10, 0x00, 0x08, // PCERR Object Header
196 0x00, 0x00, 0x01, 0x01, 0x0D, 0x10, 0x00, 0x08, // PCERR Object Header
197 0x00, 0x00, 0x01, 0x03, 0x01, 0x10, 0x00, 0x10, // OPEN object header
198 0x20, 0x05, 0x1E, 0x01, // OPEN object
199 0x00, 0x10, 0x00, 0x04, // STATEFUL-PCE-CAPABILITY
Phaneendra Manda75daf942015-08-27 20:10:02 +0530200 0x00, 0x00, 0x00, 0x05};
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530201
202 ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
203 buffer.writeBytes(errorMsg);
204
205 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
206 PcepMessage message = null;
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530207
mahesh poojary s87977d12015-08-24 19:15:37 +0530208 message = reader.readFrom(buffer);
209
Phaneendra Manda75daf942015-08-27 20:10:02 +0530210 byte[] testErrorMsg = {0};
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530211 ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
Sho SHIMIZUe090a422015-09-04 17:35:49 -0700212 assertThat(message, instanceOf(PcepErrorMsg.class));
mahesh poojary s87977d12015-08-24 19:15:37 +0530213 message.writeTo(buf);
Phaneendra Manda75daf942015-08-27 20:10:02 +0530214 int iReadLen = buf.writerIndex();
mahesh poojary s87977d12015-08-24 19:15:37 +0530215 testErrorMsg = new byte[iReadLen];
216 buf.readBytes(testErrorMsg, 0, iReadLen);
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530217
Phaneendra Manda75daf942015-08-27 20:10:02 +0530218 assertThat(testErrorMsg, is(errorMsg));
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530219 }
220
mahesh poojary s87977d12015-08-24 19:15:37 +0530221 /**
222 * This test case checks for
223 * PCEP-ERROR Object, PCEP-ERROR Object, OPEN Object
224 * in PcepErrorMsg message.
mahesh poojary s87977d12015-08-24 19:15:37 +0530225 */
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530226 @Test
Mahesh Poojary Sf1bbd362016-02-25 18:19:59 +0530227 public void errorMessageTest6() throws PcepParseException, PcepOutOfBoundMessageException {
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530228
Phaneendra Manda75daf942015-08-27 20:10:02 +0530229 byte[] errorMsg = new byte[]{0x20, 0x06, 0x00, 0x1C, // common header
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530230 0x0D, 0x10, 0x00, 0x08, // PCERR Object Header
231 0x00, 0x00, 0x01, 0x01, 0x0D, 0x10, 0x00, 0x08, // PCERR Object Header
232 0x00, 0x00, 0x01, 0x03, 0x01, 0x10, 0x00, 0x08, // OPEN object header
233 0x20, 0x05, 0x1E, 0x01 // OPEN object
234 };
235
236 ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
237 buffer.writeBytes(errorMsg);
238
239 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
240 PcepMessage message = null;
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530241
mahesh poojary s87977d12015-08-24 19:15:37 +0530242 message = reader.readFrom(buffer);
243
Phaneendra Manda75daf942015-08-27 20:10:02 +0530244 byte[] testErrorMsg = {0};
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530245 ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
Sho SHIMIZUe090a422015-09-04 17:35:49 -0700246 assertThat(message, instanceOf(PcepErrorMsg.class));
mahesh poojary s87977d12015-08-24 19:15:37 +0530247 message.writeTo(buf);
Phaneendra Manda75daf942015-08-27 20:10:02 +0530248 int iReadLen = buf.writerIndex();
mahesh poojary s87977d12015-08-24 19:15:37 +0530249 testErrorMsg = new byte[iReadLen];
250 buf.readBytes(testErrorMsg, 0, iReadLen);
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530251
Phaneendra Manda75daf942015-08-27 20:10:02 +0530252 assertThat(testErrorMsg, is(errorMsg));
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530253 }
254
mahesh poojary s87977d12015-08-24 19:15:37 +0530255 /**
256 * This test case checks for
257 * PCEP-ERROR Object, OPEN Object
258 * in PcepErrorMsg message.
mahesh poojary s87977d12015-08-24 19:15:37 +0530259 */
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530260 @Test
Mahesh Poojary Sf1bbd362016-02-25 18:19:59 +0530261 public void errorMessageTest7() throws PcepParseException, PcepOutOfBoundMessageException {
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530262
Phaneendra Manda75daf942015-08-27 20:10:02 +0530263 byte[] errorMsg = new byte[]{0x20, 0x06, 0x00, 0x14, // common header
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530264 0x0D, 0x10, 0x00, 0x08, // PCERR Object Header
265 0x00, 0x00, 0x01, 0x01, 0x01, 0x10, 0x00, 0x08, // OPEN object header
266 0x20, 0x05, 0x1E, 0x01 // OPEN object
267 };
268
269 ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
270 buffer.writeBytes(errorMsg);
271
272 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
273 PcepMessage message = null;
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530274
mahesh poojary s87977d12015-08-24 19:15:37 +0530275 message = reader.readFrom(buffer);
276
Phaneendra Manda75daf942015-08-27 20:10:02 +0530277 byte[] testErrorMsg = {0};
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530278 ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
Sho SHIMIZUe090a422015-09-04 17:35:49 -0700279 assertThat(message, instanceOf(PcepErrorMsg.class));
mahesh poojary s87977d12015-08-24 19:15:37 +0530280 message.writeTo(buf);
Phaneendra Manda75daf942015-08-27 20:10:02 +0530281 int iReadLen = buf.writerIndex();
mahesh poojary s87977d12015-08-24 19:15:37 +0530282 testErrorMsg = new byte[iReadLen];
283 buf.readBytes(testErrorMsg, 0, iReadLen);
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530284
Phaneendra Manda75daf942015-08-27 20:10:02 +0530285 assertThat(testErrorMsg, is(errorMsg));
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530286 }
287
mahesh poojary s87977d12015-08-24 19:15:37 +0530288 /**
289 * This test case checks for
290 * PCEP-ERROR Object, RP Object, PCEP-ERROR Object
291 * in PcepErrorMsg message.
mahesh poojary s87977d12015-08-24 19:15:37 +0530292 */
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530293 @Test
Mahesh Poojary Sf1bbd362016-02-25 18:19:59 +0530294 public void errorMessageTest8() throws PcepParseException, PcepOutOfBoundMessageException {
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530295
Phaneendra Manda75daf942015-08-27 20:10:02 +0530296 byte[] errorMsg = new byte[]{0x20, 0x06, 0x00, 0x20, // common header
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530297 0x0D, 0x10, 0x00, 0x08, // PCERR Object Header
mahesh poojary s87977d12015-08-24 19:15:37 +0530298 0x00, 0x00, 0x01, 0x01, 0x02, 0x10, 0x00, 0x0C, // RP Object Header
299 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x0D, 0x10, 0x00, 0x08, // PCERR Object Header
Phaneendra Manda75daf942015-08-27 20:10:02 +0530300 0x00, 0x00, 0x01, 0x03};
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530301
302 ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
303 buffer.writeBytes(errorMsg);
304
305 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
306 PcepMessage message = null;
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530307
mahesh poojary s87977d12015-08-24 19:15:37 +0530308 message = reader.readFrom(buffer);
309
Phaneendra Manda75daf942015-08-27 20:10:02 +0530310 byte[] testErrorMsg = {0};
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530311 ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
Sho SHIMIZUe090a422015-09-04 17:35:49 -0700312 assertThat(message, instanceOf(PcepErrorMsg.class));
mahesh poojary s87977d12015-08-24 19:15:37 +0530313 message.writeTo(buf);
Phaneendra Manda75daf942015-08-27 20:10:02 +0530314 int iReadLen = buf.writerIndex();
mahesh poojary s87977d12015-08-24 19:15:37 +0530315 testErrorMsg = new byte[iReadLen];
316 buf.readBytes(testErrorMsg, 0, iReadLen);
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530317
Phaneendra Manda75daf942015-08-27 20:10:02 +0530318 assertThat(testErrorMsg, is(errorMsg));
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530319 }
320
mahesh poojary s87977d12015-08-24 19:15:37 +0530321 /**
322 * This test case checks for
323 * PCEP-ERROR Object, PCEP-ERROR Object
324 * in PcepErrorMsg message.
mahesh poojary s87977d12015-08-24 19:15:37 +0530325 */
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530326 @Test
Mahesh Poojary Sf1bbd362016-02-25 18:19:59 +0530327 public void errorMessageTest9() throws PcepParseException, PcepOutOfBoundMessageException {
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530328
Phaneendra Manda75daf942015-08-27 20:10:02 +0530329 byte[] errorMsg = new byte[]{0x20, 0x06, 0x00, 0x14, // common header
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530330 0x0D, 0x10, 0x00, 0x08, // PCEP-ERROR Object Header
331 0x00, 0x00, 0x01, 0x01, 0x0D, 0x10, 0x00, 0x08, // PCEP-ERROR Object Header
Phaneendra Manda75daf942015-08-27 20:10:02 +0530332 0x00, 0x00, 0x01, 0x01};
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530333
334 ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
335 buffer.writeBytes(errorMsg);
336
337 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
338 PcepMessage message = null;
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530339
mahesh poojary s87977d12015-08-24 19:15:37 +0530340 message = reader.readFrom(buffer);
341
Phaneendra Manda75daf942015-08-27 20:10:02 +0530342 byte[] testErrorMsg = {0};
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530343 ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
Sho SHIMIZUe090a422015-09-04 17:35:49 -0700344 assertThat(message, instanceOf(PcepErrorMsg.class));
mahesh poojary s87977d12015-08-24 19:15:37 +0530345 message.writeTo(buf);
Phaneendra Manda75daf942015-08-27 20:10:02 +0530346 int iReadLen = buf.writerIndex();
mahesh poojary s87977d12015-08-24 19:15:37 +0530347 testErrorMsg = new byte[iReadLen];
348 buf.readBytes(testErrorMsg, 0, iReadLen);
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530349
Phaneendra Manda75daf942015-08-27 20:10:02 +0530350 assertThat(testErrorMsg, is(errorMsg));
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530351 }
352
mahesh poojary s87977d12015-08-24 19:15:37 +0530353 /**
354 * This test case checks for
355 * PCEP-ERROR Object, PCEP-ERROR Object
356 * in PcepErrorMsg message.
mahesh poojary s87977d12015-08-24 19:15:37 +0530357 */
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530358 @Test
Mahesh Poojary Sf1bbd362016-02-25 18:19:59 +0530359 public void errorMessageTest10() throws PcepParseException, PcepOutOfBoundMessageException {
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530360
Phaneendra Manda75daf942015-08-27 20:10:02 +0530361 byte[] errorMsg = new byte[]{0x20, 0x06, 0x00, 0x14, // common header
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530362 0x0D, 0x10, 0x00, 0x08, // PCEP-ERROR Object Header
363 0x00, 0x00, 0x01, 0x01, 0x0D, 0x10, 0x00, 0x08, // PCEP-ERROR Object Header
Phaneendra Manda75daf942015-08-27 20:10:02 +0530364 0x00, 0x00, 0x01, 0x01};
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530365
366 ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
367 buffer.writeBytes(errorMsg);
368
369 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
370 PcepMessage message = null;
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530371
mahesh poojary s87977d12015-08-24 19:15:37 +0530372 message = reader.readFrom(buffer);
373
Phaneendra Manda75daf942015-08-27 20:10:02 +0530374 byte[] testErrorMsg = {0};
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530375 ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
Sho SHIMIZUe090a422015-09-04 17:35:49 -0700376 assertThat(message, instanceOf(PcepErrorMsg.class));
mahesh poojary s87977d12015-08-24 19:15:37 +0530377 message.writeTo(buf);
Phaneendra Manda75daf942015-08-27 20:10:02 +0530378 int iReadLen = buf.writerIndex();
mahesh poojary s87977d12015-08-24 19:15:37 +0530379 testErrorMsg = new byte[iReadLen];
380 buf.readBytes(testErrorMsg, 0, iReadLen);
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530381
Phaneendra Manda75daf942015-08-27 20:10:02 +0530382 assertThat(testErrorMsg, is(errorMsg));
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530383 }
384
mahesh poojary s87977d12015-08-24 19:15:37 +0530385 /**
386 * This test case checks for
Mahesh Poojary Sf1bbd362016-02-25 18:19:59 +0530387 * LS Object, PCEP-ERROR Object
mahesh poojary s87977d12015-08-24 19:15:37 +0530388 * in PcepErrorMsg message.
mahesh poojary s87977d12015-08-24 19:15:37 +0530389 */
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530390 @Test
Mahesh Poojary Sf1bbd362016-02-25 18:19:59 +0530391 public void errorMessageTest11() throws PcepParseException, PcepOutOfBoundMessageException {
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530392
Mahesh Poojary Sf1bbd362016-02-25 18:19:59 +0530393 byte[] errorMsg = new byte[]{0x20, 0x06, 0x00, 0x1C, // common header
394 (byte) 0xE0, 0x13, 0x00, 0x10, // LS Object Header
395 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, // LS-ID
396 0x00, 0x00, 0x00, 0x10,
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530397 0x0D, 0x10, 0x00, 0x08, // PCEP-ERROR Object Header
Phaneendra Manda75daf942015-08-27 20:10:02 +0530398 0x00, 0x00, 0x01, 0x01};
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530399
400 ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
401 buffer.writeBytes(errorMsg);
402
403 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
404 PcepMessage message = null;
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530405
mahesh poojary s87977d12015-08-24 19:15:37 +0530406 message = reader.readFrom(buffer);
407
Phaneendra Manda75daf942015-08-27 20:10:02 +0530408 byte[] testErrorMsg = {0};
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530409 ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
Sho SHIMIZUe090a422015-09-04 17:35:49 -0700410 assertThat(message, instanceOf(PcepErrorMsg.class));
mahesh poojary s87977d12015-08-24 19:15:37 +0530411 message.writeTo(buf);
Phaneendra Manda75daf942015-08-27 20:10:02 +0530412 int iReadLen = buf.writerIndex();
mahesh poojary s87977d12015-08-24 19:15:37 +0530413 testErrorMsg = new byte[iReadLen];
414 buf.readBytes(testErrorMsg, 0, iReadLen);
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530415
Phaneendra Manda75daf942015-08-27 20:10:02 +0530416 assertThat(testErrorMsg, is(errorMsg));
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530417 }
418
mahesh poojary s87977d12015-08-24 19:15:37 +0530419 /**
420 * This test case checks for
421 * RP Object, PCEP-ERROR Object
422 * in PcepErrorMsg message.
mahesh poojary s87977d12015-08-24 19:15:37 +0530423 */
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530424 @Test
Mahesh Poojary Sf1bbd362016-02-25 18:19:59 +0530425 public void errorMessageTest12() throws PcepParseException, PcepOutOfBoundMessageException {
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530426
427 //RP Object, PCEP-ERROR Object
Phaneendra Manda75daf942015-08-27 20:10:02 +0530428 byte[] errorMsg = new byte[]{0x20, 0x06, 0x00, 0x18, // common header
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530429 0x02, 0x10, 0x00, 0x0C, // RP Object Header
mahesh poojary s87977d12015-08-24 19:15:37 +0530430 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x0D, 0x10, 0x00, 0x08, // PCEP-ERROR Object Header
Phaneendra Manda75daf942015-08-27 20:10:02 +0530431 0x00, 0x00, 0x01, 0x01};
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530432
433 ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
434 buffer.writeBytes(errorMsg);
435
436 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
437 PcepMessage message = null;
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530438
mahesh poojary s87977d12015-08-24 19:15:37 +0530439 message = reader.readFrom(buffer);
440
Phaneendra Manda75daf942015-08-27 20:10:02 +0530441 byte[] testErrorMsg = {0};
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530442 ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
Sho SHIMIZUe090a422015-09-04 17:35:49 -0700443 assertThat(message, instanceOf(PcepErrorMsg.class));
mahesh poojary s87977d12015-08-24 19:15:37 +0530444 message.writeTo(buf);
Phaneendra Manda75daf942015-08-27 20:10:02 +0530445 int iReadLen = buf.writerIndex();
mahesh poojary s87977d12015-08-24 19:15:37 +0530446 testErrorMsg = new byte[iReadLen];
447 buf.readBytes(testErrorMsg, 0, iReadLen);
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530448
Phaneendra Manda75daf942015-08-27 20:10:02 +0530449 assertThat(testErrorMsg, is(errorMsg));
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530450 }
451
mahesh poojary s87977d12015-08-24 19:15:37 +0530452 /**
453 * This test case checks for
454 * RP Object, RP Object, PCEP-ERROR Object
455 * in PcepErrorMsg message.
mahesh poojary s87977d12015-08-24 19:15:37 +0530456 */
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530457 @Test
Mahesh Poojary Sf1bbd362016-02-25 18:19:59 +0530458 public void errorMessageTest13() throws PcepParseException, PcepOutOfBoundMessageException {
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530459
Phaneendra Manda75daf942015-08-27 20:10:02 +0530460 byte[] errorMsg = new byte[]{0x20, 0x06, 0x00, 0x24, // common header
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530461 0x02, 0x10, 0x00, 0x0C, // RP Object Header
mahesh poojary s87977d12015-08-24 19:15:37 +0530462 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x02, 0x10, 0x00, 0x0C, // RP Object Header
463 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x0D, 0x10, 0x00, 0x08, // PCEP-ERROR Object Header
Phaneendra Manda75daf942015-08-27 20:10:02 +0530464 0x00, 0x00, 0x01, 0x01};
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530465
466 ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
467 buffer.writeBytes(errorMsg);
468
469 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
470 PcepMessage message = null;
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530471
mahesh poojary s87977d12015-08-24 19:15:37 +0530472 message = reader.readFrom(buffer);
473
Phaneendra Manda75daf942015-08-27 20:10:02 +0530474 byte[] testErrorMsg = {0};
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530475 ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
Sho SHIMIZUe090a422015-09-04 17:35:49 -0700476 assertThat(message, instanceOf(PcepErrorMsg.class));
mahesh poojary s87977d12015-08-24 19:15:37 +0530477 message.writeTo(buf);
Phaneendra Manda75daf942015-08-27 20:10:02 +0530478 int iReadLen = buf.writerIndex();
mahesh poojary s87977d12015-08-24 19:15:37 +0530479 testErrorMsg = new byte[iReadLen];
480 buf.readBytes(testErrorMsg, 0, iReadLen);
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530481
Phaneendra Manda75daf942015-08-27 20:10:02 +0530482 assertThat(testErrorMsg, is(errorMsg));
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530483 }
484
mahesh poojary s87977d12015-08-24 19:15:37 +0530485 /**
486 * This test case checks for
Mahesh Poojary Sf1bbd362016-02-25 18:19:59 +0530487 * LS Object, LS Object, PCEP-ERROR Object
mahesh poojary s87977d12015-08-24 19:15:37 +0530488 * in PcepErrorMsg message.
mahesh poojary s87977d12015-08-24 19:15:37 +0530489 */
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530490 @Test
Mahesh Poojary Sf1bbd362016-02-25 18:19:59 +0530491 public void errorMessageTest14() throws PcepParseException, PcepOutOfBoundMessageException {
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530492
Mahesh Poojary Sf1bbd362016-02-25 18:19:59 +0530493 byte[] errorMsg = new byte[]{0x20, 0x06, 0x00, 0x2C, // common header
494 (byte) 0xE0, 0x10, 0x00, 0x10, // LS Object Header
495 0x01, 0x00, 0x00, 0x03, // LS-ID
496 0x00, 0x00, 0x00, 0x00,
497 0x00, 0x00, 0x00, 0x10,
498 (byte) 0xE0, 0x10, 0x00, 0x10, // LS Object Header
499 0x01, 0x00, 0x00, 0x03, // LS-ID
500 0x00, 0x00, 0x00, 0x00,
501 0x00, 0x00, 0x00, 0x11,
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530502 0x0D, 0x10, 0x00, 0x08, // PCEP-ERROR Object Header
Phaneendra Manda75daf942015-08-27 20:10:02 +0530503 0x00, 0x00, 0x01, 0x01};
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530504
505 ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
506 buffer.writeBytes(errorMsg);
507
508 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
509 PcepMessage message = null;
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530510
mahesh poojary s87977d12015-08-24 19:15:37 +0530511 message = reader.readFrom(buffer);
512
Phaneendra Manda75daf942015-08-27 20:10:02 +0530513 byte[] testErrorMsg = {0};
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530514 ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
Sho SHIMIZUe090a422015-09-04 17:35:49 -0700515 assertThat(message, instanceOf(PcepErrorMsg.class));
mahesh poojary s87977d12015-08-24 19:15:37 +0530516 message.writeTo(buf);
Phaneendra Manda75daf942015-08-27 20:10:02 +0530517 int iReadLen = buf.writerIndex();
mahesh poojary s87977d12015-08-24 19:15:37 +0530518 testErrorMsg = new byte[iReadLen];
519 buf.readBytes(testErrorMsg, 0, iReadLen);
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530520
Phaneendra Manda75daf942015-08-27 20:10:02 +0530521 assertThat(testErrorMsg, is(errorMsg));
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530522 }
523
mahesh poojary s87977d12015-08-24 19:15:37 +0530524 /**
525 * This test case checks for
Mahesh Poojary Sf1bbd362016-02-25 18:19:59 +0530526 * PCEP-ERROR Object, LS Object, PCEP-ERROR Object
mahesh poojary s87977d12015-08-24 19:15:37 +0530527 * in PcepErrorMsg message.
mahesh poojary s87977d12015-08-24 19:15:37 +0530528 */
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530529 @Test
Mahesh Poojary Sf1bbd362016-02-25 18:19:59 +0530530 public void errorMessageTest15() throws PcepParseException, PcepOutOfBoundMessageException {
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530531
Mahesh Poojary Sf1bbd362016-02-25 18:19:59 +0530532 byte[] errorMsg = new byte[]{0x20, 0x06, 0x00, 0x24, // common header
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530533 0x0D, 0x10, 0x00, 0x08, // PCERR Object Header
Mahesh Poojary Sf1bbd362016-02-25 18:19:59 +0530534 0x00, 0x00, 0x01, 0x01,
535 (byte) 0xE0, 0x10, 0x00, 0x10, // LS Object Header
536 0x01, 0x00, 0x00, 0x03, // LS-ID
537 0x00, 0x00, 0x00, 0x00,
538 0x00, 0x00, 0x00, 0x10,
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530539 0x0D, 0x10, 0x00, 0x08, // PCEP-ERROR Object Header
Phaneendra Manda75daf942015-08-27 20:10:02 +0530540 0x00, 0x00, 0x01, 0x03};
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530541
542 ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
543 buffer.writeBytes(errorMsg);
544
545 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
546 PcepMessage message = null;
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530547
mahesh poojary s87977d12015-08-24 19:15:37 +0530548 message = reader.readFrom(buffer);
549
Phaneendra Manda75daf942015-08-27 20:10:02 +0530550 byte[] testErrorMsg = {0};
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530551 ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
Sho SHIMIZUe090a422015-09-04 17:35:49 -0700552 assertThat(message, instanceOf(PcepErrorMsg.class));
mahesh poojary s87977d12015-08-24 19:15:37 +0530553 message.writeTo(buf);
Phaneendra Manda75daf942015-08-27 20:10:02 +0530554 int iReadLen = buf.writerIndex();
mahesh poojary s87977d12015-08-24 19:15:37 +0530555 testErrorMsg = new byte[iReadLen];
556 buf.readBytes(testErrorMsg, 0, iReadLen);
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530557
Phaneendra Manda75daf942015-08-27 20:10:02 +0530558 assertThat(testErrorMsg, is(errorMsg));
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530559 }
560
mahesh poojary s87977d12015-08-24 19:15:37 +0530561 /**
562 * This test case checks for
563 * PCEP-ERROR Object, RP Object, RP Object, PCEP-ERROR Object
564 * in PcepErrorMsg message.
mahesh poojary s87977d12015-08-24 19:15:37 +0530565 */
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530566 @Test
Mahesh Poojary Sf1bbd362016-02-25 18:19:59 +0530567 public void errorMessageTest16() throws PcepParseException, PcepOutOfBoundMessageException {
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530568
Phaneendra Manda75daf942015-08-27 20:10:02 +0530569 byte[] errorMsg = new byte[]{0x20, 0x06, 0x00, 0x2C, // common header
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530570 0x0D, 0x10, 0x00, 0x08, // PCEP-ERROR Object Header
mahesh poojary s87977d12015-08-24 19:15:37 +0530571 0x00, 0x00, 0x01, 0x01, 0x02, 0x10, 0x00, 0x0C, // RP Object Header
572 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x02, 0x10, 0x00, 0x0C, // RP Object Header
573 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x0D, 0x10, 0x00, 0x08, // PCERR Object Header
Phaneendra Manda75daf942015-08-27 20:10:02 +0530574 0x00, 0x00, 0x01, 0x03};
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530575
576 ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
577 buffer.writeBytes(errorMsg);
578
579 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
580 PcepMessage message = null;
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530581
mahesh poojary s87977d12015-08-24 19:15:37 +0530582 message = reader.readFrom(buffer);
583
Phaneendra Manda75daf942015-08-27 20:10:02 +0530584 byte[] testErrorMsg = {0};
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530585 ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
Sho SHIMIZUe090a422015-09-04 17:35:49 -0700586 assertThat(message, instanceOf(PcepErrorMsg.class));
mahesh poojary s87977d12015-08-24 19:15:37 +0530587 message.writeTo(buf);
Phaneendra Manda75daf942015-08-27 20:10:02 +0530588 int iReadLen = buf.writerIndex();
mahesh poojary s87977d12015-08-24 19:15:37 +0530589 testErrorMsg = new byte[iReadLen];
590 buf.readBytes(testErrorMsg, 0, iReadLen);
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530591
Phaneendra Manda75daf942015-08-27 20:10:02 +0530592 assertThat(testErrorMsg, is(errorMsg));
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530593 }
594
mahesh poojary s87977d12015-08-24 19:15:37 +0530595 /**
596 * This test case checks for
Mahesh Poojary Sf1bbd362016-02-25 18:19:59 +0530597 * PCEP-ERROR Object, LS Object, LS Object, PCEP-ERROR Object
mahesh poojary s87977d12015-08-24 19:15:37 +0530598 * in PcepErrorMsg message.
mahesh poojary s87977d12015-08-24 19:15:37 +0530599 */
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530600 @Test
Mahesh Poojary Sf1bbd362016-02-25 18:19:59 +0530601 public void errorMessageTest17() throws PcepParseException, PcepOutOfBoundMessageException {
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530602
Mahesh Poojary Sf1bbd362016-02-25 18:19:59 +0530603 byte[] errorMsg = new byte[]{0x20, 0x06, 0x00, 0x34, // common header
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530604 0x0D, 0x10, 0x00, 0x08, // PCEP-ERROR Object Header
Mahesh Poojary Sf1bbd362016-02-25 18:19:59 +0530605 0x00, 0x00, 0x01, 0x01,
606 (byte) 0xE0, 0x10, 0x00, 0x10, // LS Object Header
607 0x01, 0x00, 0x00, 0x03, // LS-ID
608 0x00, 0x00, 0x00, 0x00,
609 0x00, 0x00, 0x00, 0x10,
610 (byte) 0xE0, 0x10, 0x00, 0x10, // LS Object Header
611 0x01, 0x00, 0x00, 0x03, // LS-ID
612 0x00, 0x00, 0x00, 0x00,
613 0x00, 0x00, 0x00, 0x11,
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530614 0x0D, 0x10, 0x00, 0x08, // PCEP-ERROR Object Header
Phaneendra Manda75daf942015-08-27 20:10:02 +0530615 0x00, 0x00, 0x01, 0x03};
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530616
617 ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
618 buffer.writeBytes(errorMsg);
619
620 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
621 PcepMessage message = null;
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530622
mahesh poojary s87977d12015-08-24 19:15:37 +0530623 message = reader.readFrom(buffer);
624
Phaneendra Manda75daf942015-08-27 20:10:02 +0530625 byte[] testErrorMsg = {0};
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530626 ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
Sho SHIMIZUe090a422015-09-04 17:35:49 -0700627 assertThat(message, instanceOf(PcepErrorMsg.class));
mahesh poojary s87977d12015-08-24 19:15:37 +0530628 message.writeTo(buf);
Phaneendra Manda75daf942015-08-27 20:10:02 +0530629 int iReadLen = buf.writerIndex();
mahesh poojary s87977d12015-08-24 19:15:37 +0530630 testErrorMsg = new byte[iReadLen];
631 buf.readBytes(testErrorMsg, 0, iReadLen);
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530632
Phaneendra Manda75daf942015-08-27 20:10:02 +0530633 assertThat(testErrorMsg, is(errorMsg));
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530634 }
635
mahesh poojary s87977d12015-08-24 19:15:37 +0530636 /**
637 * This test case checks for
638 * PCEP-ERROR Object, PCEP-ERROR Object, RP Object, RP Object, PCEP-ERROR Object, PCEP-ERROR Object
639 * in PcepErrorMsg message.
mahesh poojary s87977d12015-08-24 19:15:37 +0530640 */
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530641 @Test
Mahesh Poojary Sf1bbd362016-02-25 18:19:59 +0530642 public void errorMessageTest18() throws PcepParseException, PcepOutOfBoundMessageException {
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530643
Phaneendra Manda75daf942015-08-27 20:10:02 +0530644 byte[] errorMsg = new byte[]{0x20, 0x06, 0x00, 0x3C, // common header
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530645 0x0D, 0x10, 0x00, 0x08, // PCEP-ERROR Object Header
mahesh poojary s87977d12015-08-24 19:15:37 +0530646 0x00, 0x00, 0x01, 0x01, 0x0D, 0x10, 0x00, 0x08, // PCEP-ERROR Object Header
647 0x00, 0x00, 0x01, 0x03, 0x02, 0x10, 0x00, 0x0C, // RP Object Header
648 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x02, 0x10, 0x00, 0x0C, // RP Object Header
649 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x0D, 0x10, 0x00, 0x08, // PCEP-ERROR Object Header
650 0x00, 0x00, 0x01, 0x04, 0x0D, 0x10, 0x00, 0x08, // PCEP-ERROR Object Header
Phaneendra Manda75daf942015-08-27 20:10:02 +0530651 0x00, 0x00, 0x01, 0x06};
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530652
653 ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
654 buffer.writeBytes(errorMsg);
655
656 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
657 PcepMessage message = null;
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530658
mahesh poojary s87977d12015-08-24 19:15:37 +0530659 message = reader.readFrom(buffer);
660
Phaneendra Manda75daf942015-08-27 20:10:02 +0530661 byte[] testErrorMsg = {0};
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530662 ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
Sho SHIMIZUe090a422015-09-04 17:35:49 -0700663 assertThat(message, instanceOf(PcepErrorMsg.class));
mahesh poojary s87977d12015-08-24 19:15:37 +0530664 message.writeTo(buf);
Phaneendra Manda75daf942015-08-27 20:10:02 +0530665 int iReadLen = buf.writerIndex();
mahesh poojary s87977d12015-08-24 19:15:37 +0530666 testErrorMsg = new byte[iReadLen];
667 buf.readBytes(testErrorMsg, 0, iReadLen);
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530668
Phaneendra Manda75daf942015-08-27 20:10:02 +0530669 assertThat(testErrorMsg, is(errorMsg));
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530670 }
671
mahesh poojary s87977d12015-08-24 19:15:37 +0530672 /**
673 * This test case checks for
Mahesh Poojary Sf1bbd362016-02-25 18:19:59 +0530674 * PCEP-ERROR Object, PCEP-ERROR Object, LS Object, LS Object, PCEP-ERROR Object, PCEP-ERROR Object
mahesh poojary s87977d12015-08-24 19:15:37 +0530675 * in PcepErrorMsg message.
mahesh poojary s87977d12015-08-24 19:15:37 +0530676 */
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530677 @Test
Mahesh Poojary Sf1bbd362016-02-25 18:19:59 +0530678 public void errorMessageTest19() throws PcepParseException, PcepOutOfBoundMessageException {
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530679
Mahesh Poojary Sf1bbd362016-02-25 18:19:59 +0530680 byte[] errorMsg = new byte[]{0x20, 0x06, 0x00, 0x44, // common header
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530681 0x0D, 0x10, 0x00, 0x08, // PCERR Object Header
Mahesh Poojary Sf1bbd362016-02-25 18:19:59 +0530682 0x00, 0x00, 0x01, 0x01,
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530683 0x0D, 0x10, 0x00, 0x08, // PCERR Object Header
Mahesh Poojary Sf1bbd362016-02-25 18:19:59 +0530684 0x00, 0x00, 0x01, 0x03,
685 (byte) 0xE0, 0x10, 0x00, 0x10, // LS Object Header
686 0x01, 0x00, 0x00, 0x03, // LS-ID
687 0x00, 0x00, 0x00, 0x00,
688 0x00, 0x00, 0x00, 0x10,
689 (byte) 0xE0, 0x10, 0x00, 0x10, // LS Object Header
690 0x01, 0x00, 0x00, 0x03, // LS-ID
691 0x00, 0x00, 0x00, 0x00,
692 0x00, 0x00, 0x00, 0x11,
693 0x0D, 0x10, 0x00, 0x08, // PCERR Object Header
694 0x00, 0x00, 0x01, 0x04, // PCERR Object Header
695 0x0D, 0x10, 0x00, 0x08,
Phaneendra Manda75daf942015-08-27 20:10:02 +0530696 0x00, 0x00, 0x01, 0x06};
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530697
698 ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
699 buffer.writeBytes(errorMsg);
700
701 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
702 PcepMessage message = null;
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530703
mahesh poojary s87977d12015-08-24 19:15:37 +0530704 message = reader.readFrom(buffer);
705
Phaneendra Manda75daf942015-08-27 20:10:02 +0530706 byte[] testErrorMsg = {0};
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530707 ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
Sho SHIMIZUe090a422015-09-04 17:35:49 -0700708 assertThat(message, instanceOf(PcepErrorMsg.class));
mahesh poojary s87977d12015-08-24 19:15:37 +0530709 message.writeTo(buf);
Phaneendra Manda75daf942015-08-27 20:10:02 +0530710 int iReadLen = buf.writerIndex();
mahesh poojary s87977d12015-08-24 19:15:37 +0530711 testErrorMsg = new byte[iReadLen];
712 buf.readBytes(testErrorMsg, 0, iReadLen);
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530713
Phaneendra Manda75daf942015-08-27 20:10:02 +0530714 assertThat(testErrorMsg, is(errorMsg));
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530715 }
716
mahesh poojary s87977d12015-08-24 19:15:37 +0530717 /**
718 * This test case checks for
719 * PCEP-ERROR Object, RP Object, RP Object, PCEP-ERROR Object, PCEP-ERROR Object,
Mahesh Poojary Sf1bbd362016-02-25 18:19:59 +0530720 * LS Object, PCEP-ERROR Object
mahesh poojary s87977d12015-08-24 19:15:37 +0530721 * in PcepErrorMsg message.
mahesh poojary s87977d12015-08-24 19:15:37 +0530722 */
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530723 @Test
Mahesh Poojary Sf1bbd362016-02-25 18:19:59 +0530724 public void errorMessageTest20() throws PcepParseException, PcepOutOfBoundMessageException {
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530725
Mahesh Poojary Sf1bbd362016-02-25 18:19:59 +0530726 byte[] errorMsg = new byte[]{0x20, 0x06, 0x00, 0x4C, // common header
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530727 0x0D, 0x10, 0x00, 0x08, // PCEP-ERROR Object Header
mahesh poojary s87977d12015-08-24 19:15:37 +0530728 0x00, 0x00, 0x01, 0x01, 0x02, 0x10, 0x00, 0x0C, // RP Object Header
729 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x02, 0x10, 0x00, 0x0C, // RP Object Header
730 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x0D, 0x10, 0x00, 0x08, // PCERR Object Header
731 0x00, 0x00, 0x01, 0x04, 0x0D, 0x10, 0x00, 0x08, // PCERR Object Header
Mahesh Poojary Sf1bbd362016-02-25 18:19:59 +0530732 0x00, 0x00, 0x01, 0x06, (byte) 0xE0, 0x10, 0x00, 0x10, // LS Object Header
733 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, // LS-ID
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530734 0x0D, 0x10, 0x00, 0x08, // PCERR Object Header
Phaneendra Manda75daf942015-08-27 20:10:02 +0530735 0x00, 0x00, 0x01, 0x06};
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530736
737 ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
738 buffer.writeBytes(errorMsg);
739
740 PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
741 PcepMessage message = null;
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530742
mahesh poojary s87977d12015-08-24 19:15:37 +0530743 message = reader.readFrom(buffer);
744
Phaneendra Manda75daf942015-08-27 20:10:02 +0530745 byte[] testErrorMsg = {0};
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530746 ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
Sho SHIMIZUe090a422015-09-04 17:35:49 -0700747 assertThat(message, instanceOf(PcepErrorMsg.class));
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530748
mahesh poojary s87977d12015-08-24 19:15:37 +0530749 message.writeTo(buf);
Phaneendra Manda75daf942015-08-27 20:10:02 +0530750 int iReadLen = buf.writerIndex();
mahesh poojary s87977d12015-08-24 19:15:37 +0530751 testErrorMsg = new byte[iReadLen];
752 buf.readBytes(testErrorMsg, 0, iReadLen);
753
Phaneendra Manda75daf942015-08-27 20:10:02 +0530754 assertThat(testErrorMsg, is(errorMsg));
Mahesh Poojary S1c356e32015-08-21 15:05:30 +0530755 }
756}