use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.Open in project bgpcep by opendaylight.
the class FiniteStateMachineTest method testErrorOneSeven.
/**
* KeepWaitTimer expired.
*
* @throws Exception exception
*/
@Test
public void testErrorOneSeven() throws Exception {
this.serverSession.channelActive(null);
assertEquals(1, this.msgsSend.size());
assertTrue(this.msgsSend.get(0) instanceof Open);
this.serverSession.handleMessage(this.openMsg);
checkEquals(() -> {
for (final Notification m : this.msgsSend) {
if (m instanceof Pcerr) {
final Errors obj = ((Pcerr) m).getPcerrMessage().getErrors().get(0);
assertEquals(new Short((short) 1), obj.getErrorObject().getType());
assertEquals(new Short((short) 7), obj.getErrorObject().getValue());
}
}
});
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.Open in project bgpcep by opendaylight.
the class FiniteStateMachineTest method testSessionCharsAccMe.
/**
* Mock PCE does not accept session characteristics the first time.
*
* @throws Exception exception
*/
@Test
public void testSessionCharsAccMe() throws Exception {
this.serverSession.channelActive(null);
assertEquals(1, this.msgsSend.size());
assertTrue(this.msgsSend.get(0) instanceof Open);
final Open remote = (Open) this.msgsSend.get(0);
this.serverSession.handleMessage(this.openMsg);
assertEquals(2, this.msgsSend.size());
assertTrue(this.msgsSend.get(1) instanceof Keepalive);
this.serverSession.handleMessage(Util.createErrorMessage(PCEPErrors.NON_ACC_NEG_SESSION_CHAR, remote.getOpenMessage().getOpen()));
assertEquals(3, this.msgsSend.size());
assertTrue(this.msgsSend.get(2) instanceof Open);
this.serverSession.handleMessage(this.kaMsg);
assertEquals(this.serverSession.getState(), DefaultPCEPSessionNegotiator.State.FINISHED);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.Open in project bgpcep by opendaylight.
the class PCEPValidatorTest method testOpenMsg.
@Test
public void testOpenMsg() throws IOException, PCEPDeserializerException {
final ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPOpenMessage1.bin"));
final PCEPOpenMessageParser parser = new PCEPOpenMessageParser(this.ctx.getObjectHandlerRegistry());
final OpenMessageBuilder builder = new OpenMessageBuilder();
final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.OpenBuilder b = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.OpenBuilder();
b.setProcessingRule(false);
b.setIgnore(false);
b.setVersion(new ProtocolVersion((short) 1));
b.setKeepalive((short) 30);
b.setDeadTimer((short) 120);
b.setSessionId((short) 1);
b.setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.open.TlvsBuilder().build());
builder.setOpen(b.build());
assertEquals(new OpenBuilder().setOpenMessage(builder.build()).build(), parser.parseMessage(result.slice(4, result.readableBytes() - 4), Collections.emptyList()));
final ByteBuf buf = Unpooled.buffer(result.readableBytes());
parser.serializeMessage(new OpenBuilder().setOpenMessage(builder.build()).build(), buf);
assertArrayEquals(result.array(), buf.array());
try {
parser.serializeMessage(new OpenBuilder().setOpenMessage(new OpenMessageBuilder().build()).build(), null);
fail();
} catch (final IllegalArgumentException e) {
assertEquals("Open Object must be present in Open Message.", e.getMessage());
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.Open in project bgpcep by opendaylight.
the class BasePCEPSessionProposalFactory method getSessionProposal.
@Override
public Open getSessionProposal(final InetSocketAddress address, final int sessionId, final PCEPPeerProposal peerProposal) {
final OpenBuilder oBuilder = new OpenBuilder();
oBuilder.setSessionId((short) sessionId);
oBuilder.setKeepalive((short) BasePCEPSessionProposalFactory.this.keepAlive);
if (BasePCEPSessionProposalFactory.this.keepAlive == 0) {
oBuilder.setDeadTimer((short) 0);
} else {
oBuilder.setDeadTimer((short) BasePCEPSessionProposalFactory.this.deadTimer);
}
final TlvsBuilder builder = new TlvsBuilder();
addTlvs(address, builder);
if (peerProposal != null) {
peerProposal.setPeerSpecificProposal(address, builder);
}
return oBuilder.setTlvs(builder.build()).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.Open in project bgpcep by opendaylight.
the class APITest method testBgpExtendedMessageUtil.
@Test
public void testBgpExtendedMessageUtil() {
final List<BgpParameters> params = new ArrayList<>();
final List<OptionalCapabilities> capas = new ArrayList<>();
capas.add(new OptionalCapabilitiesBuilder().setCParameters(new CParametersBuilder().addAugmentation(CParameters1.class, new CParameters1Builder().setMultiprotocolCapability(new MultiprotocolCapabilityBuilder().build()).build()).build()).build());
capas.add(new OptionalCapabilitiesBuilder().setCParameters(BgpExtendedMessageUtil.EXTENDED_MESSAGE_CAPABILITY).build());
params.add(new BgpParametersBuilder().setOptionalCapabilities(capas).build());
final Open open1 = new OpenBuilder().setBgpParameters(params).build();
assertEquals(true, BgpExtendedMessageUtil.advertizedBgpExtendedMessageCapability(open1));
}
Aggregations