use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.KeepaliveBuilder in project bgpcep by opendaylight.
the class ParserTest method testKeepAliveMsg.
@Test
public void testKeepAliveMsg() throws BGPParsingException, BGPDocumentedException {
final Notification keepAlive = new KeepaliveBuilder().build();
final ByteBuf buffer = Unpooled.buffer();
ParserTest.reg.serializeMessage(keepAlive, buffer);
assertArrayEquals(keepAliveBMsg, ByteArray.getAllBytes(buffer));
final Notification m = ParserTest.reg.parseMessage(Unpooled.copiedBuffer(ByteArray.getAllBytes(buffer)), null);
assertTrue(m instanceof Keepalive);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.KeepaliveBuilder in project bgpcep by opendaylight.
the class AbstractBGPSessionNegotiator method handleOpen.
private synchronized void handleOpen(final Open openObj) {
final IpAddress remoteIp = getRemoteIp();
final BGPSessionPreferences preferences = this.registry.getPeerPreferences(remoteIp);
try {
final BGPSessionListener peer = this.registry.getPeer(remoteIp, getSourceId(openObj, preferences), getDestinationId(openObj, preferences), openObj);
sendMessage(new KeepaliveBuilder().build());
this.state = State.OPEN_CONFIRM;
this.session = new BGPSessionImpl(peer, this.channel, openObj, preferences, this.registry);
this.session.setChannelExtMsgCoder(openObj);
LOG.debug("Channel {} moved to OPEN_CONFIRM state with remote proposal {}", this.channel, openObj);
} catch (final BGPDocumentedException e) {
LOG.warn("Channel {} negotiation failed", this.channel, e);
negotiationFailed(e);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.KeepaliveBuilder in project bgpcep by opendaylight.
the class PCEPValidatorTest method testKeepAliveMsg.
@Test
public void testKeepAliveMsg() throws IOException, PCEPDeserializerException {
final ByteBuf result = Unpooled.wrappedBuffer(new byte[] { 32, 2, 0, 4 });
final PCEPKeepAliveMessageParser parser = new PCEPKeepAliveMessageParser(this.objectRegistry);
final KeepaliveBuilder builder = new KeepaliveBuilder().setKeepaliveMessage(new KeepaliveMessageBuilder().build());
assertEquals(builder.build(), parser.parseMessage(result.slice(4, result.readableBytes() - 4), Collections.emptyList()));
final ByteBuf buf = Unpooled.buffer(result.readableBytes());
parser.serializeMessage(builder.build(), buf);
assertArrayEquals(result.array(), buf.array());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.KeepaliveBuilder in project bgpcep by opendaylight.
the class FSMTest method sendNotification.
@Test
public void sendNotification() {
this.clientSession.channelActive(null);
this.clientSession.handleMessage(this.classicOpen);
this.clientSession.handleMessage(new KeepaliveBuilder().build());
assertEquals(this.clientSession.getState(), BGPClientSessionNegotiator.State.FINISHED);
this.clientSession.handleMessage(new OpenBuilder().setMyAsNumber(30).setHoldTimer(3).setVersion(new ProtocolVersion((short) 4)).build());
assertEquals(3, this.receivedMsgs.size());
assertTrue(this.receivedMsgs.get(2) instanceof Notify);
final Notification m = this.receivedMsgs.get(2);
assertEquals(BGPError.FSM_ERROR.getCode(), ((Notify) m).getErrorCode().shortValue());
assertEquals(BGPError.FSM_ERROR.getSubcode(), ((Notify) m).getErrorSubcode().shortValue());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.KeepaliveBuilder in project bgpcep by opendaylight.
the class PCEPTestingToolTest method testSimpleSessionListener.
@Test
public void testSimpleSessionListener() {
final TestingSessionListener ssl = new TestingSessionListener();
assertEquals(0, ssl.messages().size());
ssl.onMessage(null, new KeepaliveBuilder().setKeepaliveMessage(new KeepaliveMessageBuilder().build()).build());
assertEquals(1, ssl.messages().size());
assertTrue(ssl.messages().get(0) instanceof KeepaliveMessage);
assertFalse(ssl.isUp());
ssl.onSessionUp(null);
assertTrue(ssl.isUp());
ssl.onSessionDown(null, null);
assertFalse(ssl.isUp());
}
Aggregations