use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.Notify in project bgpcep by opendaylight.
the class BGPSessionImplTest method testBGPSession.
@Test
public void testBGPSession() throws BGPDocumentedException {
this.bgpSession.sessionUp();
assertEquals(State.UP, this.bgpSession.getState());
assertEquals(AS_NUMBER, this.bgpSession.getAsNumber());
assertEquals(BGP_ID, this.bgpSession.getBgpId());
assertEquals(1, this.bgpSession.getAdvertisedTableTypes().size());
assertEquals(State.UP, this.listener.getState());
this.bgpSession.handleMessage(new UpdateBuilder().build());
assertEquals(1, this.listener.getListMsg().size());
assertTrue(this.listener.getListMsg().get(0) instanceof Update);
this.bgpSession.close();
assertEquals(State.IDLE, this.bgpSession.getState());
assertEquals(1, this.receivedMsgs.size());
assertTrue(this.receivedMsgs.get(0) instanceof Notify);
final Notify error = (Notify) this.receivedMsgs.get(0);
assertEquals(BGPError.CEASE.getCode(), error.getErrorCode());
assertEquals(BGPError.CEASE.getSubcode(), error.getErrorSubcode());
verify(this.speakerListener).close();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.Notify in project bgpcep by opendaylight.
the class BGPSessionImplTest method testHoldTimerExpire.
@Test
public void testHoldTimerExpire() throws InterruptedException {
this.bgpSession.sessionUp();
checkIdleState(this.listener);
assertEquals(3, this.receivedMsgs.size());
assertTrue(this.receivedMsgs.get(2) instanceof Notify);
final Notify error = (Notify) this.receivedMsgs.get(2);
assertEquals(BGPError.HOLD_TIMER_EXPIRED.getCode(), error.getErrorCode());
assertEquals(BGPError.HOLD_TIMER_EXPIRED.getSubcode(), error.getErrorSubcode());
verify(this.speakerListener).close();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.Notify in project bgpcep by opendaylight.
the class BGPNotificationMessageParser method serializeMessage.
/**
* Serializes BGP Notification message.
*
* @param msg to be serialized
* @param bytes ByteBuf where the message will be serialized
*/
@Override
public void serializeMessage(final Notification msg, final ByteBuf bytes) {
checkArgument(msg instanceof Notify, "Message needs to be of type Notify");
final Notify ntf = (Notify) msg;
final ByteBuf msgBody = Unpooled.buffer().writeByte(ntf.getErrorCode().toJava()).writeByte(ntf.getErrorSubcode().toJava());
final byte[] data = ntf.getData();
if (data != null) {
msgBody.writeBytes(data);
}
if (LOG.isTraceEnabled()) {
LOG.trace("Notification message serialized to: {}", ByteBufUtil.hexDump(msgBody));
}
MessageUtil.formatMessage(TYPE, msgBody, bytes);
}
Aggregations