Search in sources :

Example 41 with Notify

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();
}
Also used : Notify(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.Notify) UpdateBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.UpdateBuilder) Update(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.Update) Test(org.junit.Test)

Example 42 with Notify

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();
}
Also used : Notify(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.Notify) Test(org.junit.Test)

Example 43 with Notify

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);
}
Also used : Notify(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.Notify) ByteBuf(io.netty.buffer.ByteBuf)

Aggregations

Test (org.junit.Test)16 Notify (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.Notify)12 MapNotify (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapNotify)8 Notification (org.opendaylight.yangtools.yang.binding.Notification)6 ArrayList (java.util.ArrayList)5 JAXBException (javax.xml.bind.JAXBException)5 Notify (org.oasis_open.docs.wsn.b_2.Notify)5 Open (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.Open)5 JMSException (javax.jms.JMSException)4 AclInterface (org.opendaylight.netvirt.aclservice.api.utils.AclInterface)4 MappingRecord (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecord)4 Message (javax.jms.Message)3 TextMessage (javax.jms.TextMessage)3 NotificationMessageHolderType (org.oasis_open.docs.wsn.b_2.NotificationMessageHolderType)3 BGPDocumentedException (org.opendaylight.protocol.bgp.parser.BGPDocumentedException)3 Ipv4AddressNoZone (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4AddressNoZone)3 OpenBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.OpenBuilder)3 Optional (com.google.common.base.Optional)2 SuppressFBWarnings (edu.umd.cs.findbugs.annotations.SuppressFBWarnings)2 ByteBuf (io.netty.buffer.ByteBuf)2