Search in sources :

Example 1 with InitiatedPCInitiateMessageParser

use of org.opendaylight.protocol.pcep.ietf.initiated.InitiatedPCInitiateMessageParser in project bgpcep by opendaylight.

the class PCEPValidatorTest method testPcinitMsg.

@Test
public void testPcinitMsg() throws IOException, PCEPDeserializerException {
    new InitiatedActivator().start(ctx);
    final ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/Pcinit.bin"));
    final InitiatedPCInitiateMessageParser parser = new InitiatedPCInitiateMessageParser(this.ctx.getObjectHandlerRegistry());
    final PcinitiateMessageBuilder builder = new PcinitiateMessageBuilder().setRequests(List.of(new RequestsBuilder().setSrp(this.srp).setLsp(this.lspSrp).setEro(this.ero).setLspa(this.lspa).setMetrics(List.of(this.metrics)).setIro(this.iro).build()));
    assertEquals(new PcinitiateBuilder().setPcinitiateMessage(builder.build()).build(), parser.parseMessage(result.slice(4, result.readableBytes() - 4), List.of()));
    final ByteBuf buf = Unpooled.buffer(result.readableBytes());
    parser.serializeMessage(new PcinitiateBuilder().setPcinitiateMessage(builder.build()).build(), buf);
    assertArrayEquals(result.array(), buf.array());
}
Also used : PcinitiateMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.initiated.rev200720.pcinitiate.message.PcinitiateMessageBuilder) InitiatedPCInitiateMessageParser(org.opendaylight.protocol.pcep.ietf.initiated.InitiatedPCInitiateMessageParser) PcinitiateBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.initiated.rev200720.PcinitiateBuilder) InitiatedActivator(org.opendaylight.protocol.pcep.ietf.initiated.InitiatedActivator) RequestsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.initiated.rev200720.pcinitiate.message.pcinitiate.message.RequestsBuilder) ByteBuf(io.netty.buffer.ByteBuf) Test(org.junit.Test)

Aggregations

ByteBuf (io.netty.buffer.ByteBuf)1 Test (org.junit.Test)1 InitiatedActivator (org.opendaylight.protocol.pcep.ietf.initiated.InitiatedActivator)1 InitiatedPCInitiateMessageParser (org.opendaylight.protocol.pcep.ietf.initiated.InitiatedPCInitiateMessageParser)1 PcinitiateBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.initiated.rev200720.PcinitiateBuilder)1 PcinitiateMessageBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.initiated.rev200720.pcinitiate.message.PcinitiateMessageBuilder)1 RequestsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.initiated.rev200720.pcinitiate.message.pcinitiate.message.RequestsBuilder)1