use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.Pcupd 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());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.Pcupd in project bgpcep by opendaylight.
the class StatefulPCUpdateRequestMessageParser method serializeMessage.
@Override
public void serializeMessage(final Message message, final ByteBuf out) {
checkArgument(message instanceof Pcupd, "Wrong instance of Message. Passed instance of %s. Need Pcupd.", message.getClass());
final Pcupd msg = (Pcupd) message;
final List<Updates> updates = msg.getPcupdMessage().getUpdates();
final ByteBuf buffer = Unpooled.buffer();
for (final Updates update : updates) {
serializeUpdate(update, buffer);
}
MessageUtil.formatMessage(TYPE, buffer, out);
}
Aggregations