use of org.opendaylight.protocol.pcep.ietf.stateful.StatefulPCUpdateRequestMessageParser in project bgpcep by opendaylight.
the class PCEPValidatorTest method testUnexpectedRroObjectInPcUpdMsg.
@Test
public void testUnexpectedRroObjectInPcUpdMsg() throws PCEPDeserializerException {
final byte[] badUpdateMsg = { (byte) 0x20, (byte) 0x0b, (byte) 0x00, (byte) 0x50, /* SRP, LSP and ERO objects */
(byte) 0x21, (byte) 0x12, (byte) 0x00, (byte) 0x0c, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x01, (byte) 0x20, (byte) 0x10, (byte) 0x00, (byte) 0x08, (byte) 0x00, (byte) 0x00, (byte) 0x10, (byte) 0x09, (byte) 0x07, (byte) 0x10, (byte) 0x00, (byte) 0x14, (byte) 0x01, (byte) 0x08, (byte) 0x05, (byte) 0x05, (byte) 0x05, (byte) 0x03, (byte) 0x18, (byte) 0x00, (byte) 0x01, (byte) 0x08, (byte) 0x08, (byte) 0x08, (byte) 0x08, (byte) 0x04, (byte) 0x18, (byte) 0x00, /* RRO object */
(byte) 0x08, (byte) 0x10, (byte) 0x00, (byte) 0x24, (byte) 0x01, (byte) 0x08, (byte) 0x0a, (byte) 0x00, (byte) 0x00, (byte) 0x83, (byte) 0x20, (byte) 0x20, (byte) 0x03, (byte) 0x08, (byte) 0x01, (byte) 0x01, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x01, (byte) 0x08, (byte) 0x0a, (byte) 0x00, (byte) 0x09, (byte) 0xde, (byte) 0x20, (byte) 0x00, (byte) 0x03, (byte) 0x08, (byte) 0x01, (byte) 0x01, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00 };
new InitiatedActivator().start(ctx);
final StatefulPCUpdateRequestMessageParser parser = new StatefulPCUpdateRequestMessageParser(this.ctx.getObjectHandlerRegistry());
final ByteBuf buf = Unpooled.wrappedBuffer(badUpdateMsg);
final List<Message> errors = new ArrayList<>();
parser.parseMessage(buf.slice(4, buf.readableBytes() - 4), errors);
assertFalse(errors.isEmpty());
assertEquals(new PcerrBuilder().setPcerrMessage(new PcerrMessageBuilder().setErrors(List.of(new ErrorsBuilder().setErrorObject(new ErrorObjectBuilder().setType(Uint8.valueOf(6)).setValue(Uint8.valueOf(10)).build()).build())).build()).build(), errors.get(0));
}
use of org.opendaylight.protocol.pcep.ietf.stateful.StatefulPCUpdateRequestMessageParser in project bgpcep by opendaylight.
the class PCEPValidatorTest method testUpdMsg.
@Test
public void testUpdMsg() throws IOException, PCEPDeserializerException {
new InitiatedActivator().start(ctx);
final StatefulPCUpdateRequestMessageParser parser = new StatefulPCUpdateRequestMessageParser(this.ctx.getObjectHandlerRegistry());
final PathBuilder pBuilder = new PathBuilder().setEro(this.ero).setLspa(this.lspa);
final PcupdMessageBuilder builder = new PcupdMessageBuilder().setUpdates(List.of(new UpdatesBuilder().setSrp(this.srp).setLsp(this.lspSrp).setPath(pBuilder.build()).build()));
ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCUpd.2.bin"));
assertEquals(new PcupdBuilder().setPcupdMessage(builder.build()).build(), parser.parseMessage(result.slice(4, result.readableBytes() - 4), List.of()));
ByteBuf buf = Unpooled.buffer(result.readableBytes());
parser.serializeMessage(new PcupdBuilder().setPcupdMessage(builder.build()).build(), buf);
assertArrayEquals(result.array(), buf.array());
builder.setUpdates(List.of(new UpdatesBuilder().setSrp(this.srp).setLsp(this.lspSrp).setPath(pBuilder.build()).build(), new UpdatesBuilder().setSrp(this.srp).setLsp(this.lspSrp).setPath(new PathBuilder().setEro(this.ero).setLspa(this.lspa).build()).build()));
result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCUpd.5.bin"));
assertEquals(new PcupdBuilder().setPcupdMessage(builder.build()).build(), parser.parseMessage(result.slice(4, result.readableBytes() - 4), List.of()));
buf = Unpooled.buffer(result.readableBytes());
parser.serializeMessage(new PcupdBuilder().setPcupdMessage(builder.build()).build(), buf);
assertArrayEquals(result.array(), buf.array());
}
Aggregations