use of org.opendaylight.yangtools.yang.binding.Notification in project bgpcep by opendaylight.
the class FiniteStateMachineTest method testErrorOneOne.
/**
* Sending different PCEP Message than Open in session establishment phase.
*
* @throws Exception exception
*/
@Test
public void testErrorOneOne() throws Exception {
this.serverSession.channelActive(null);
assertEquals(1, this.msgsSend.size());
assertTrue(this.msgsSend.get(0) instanceof Open);
this.serverSession.handleMessage(this.kaMsg);
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) 1), obj.getErrorObject().getValue());
}
}
});
}
use of org.opendaylight.yangtools.yang.binding.Notification 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.yangtools.yang.binding.Notification in project bgpcep by opendaylight.
the class ParserTest method testRouteRefreshMsg.
@Test
public void testRouteRefreshMsg() throws BGPDocumentedException, BGPParsingException {
final Notification rrMsg = new RouteRefreshBuilder().setAfi(Ipv4AddressFamily.class).setSafi(UnicastSubsequentAddressFamily.class).build();
final ByteBuf buffer = Unpooled.buffer();
ParserTest.reg.serializeMessage(rrMsg, buffer);
assertArrayEquals(RR_MSG, ByteArray.getAllBytes(buffer));
final Notification m = ParserTest.reg.parseMessage(Unpooled.copiedBuffer(ByteArray.getAllBytes(buffer)), null);
assertTrue(m instanceof RouteRefresh);
}
use of org.opendaylight.yangtools.yang.binding.Notification in project bgpcep by opendaylight.
the class ParserTest method testParseUpdMsgWithMandatoryAttributesPresent.
@Test
public void testParseUpdMsgWithMandatoryAttributesPresent() throws BGPDocumentedException, BGPParsingException {
try {
final Notification msg = reg.parseMessage(Unpooled.copiedBuffer(updMsgWithMandatoryAttributesPresent), null);
assertTrue(msg instanceof Update);
} catch (final BGPDocumentedException e) {
fail("Exception should not have occured.");
}
}
use of org.opendaylight.yangtools.yang.binding.Notification in project bgpcep by opendaylight.
the class ParserTest method testOpenMessage.
/*
* ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff <- marker
* 00 3d <- length (61) - including header
* 01 <- message type
* 04 <- BGP version
* 00 64 <- My AS Number (AS TRANS in this case)
* 00 b4 <- Hold Time
* 00 00 00 00 <- BGP Identifier
* 20 <- Optional Parameters Length
* 02 <- opt. param. type (capabilities)
* 06 <- length
* 01 <- capability code (MP Extensions for BGP4)
* 04 <- length
* 00 01 00 01 <- AFI 1, SAFI 1
* 02 <- opt. param. type (capabilities)
* 06 <- length
* 01 <- capability code (MP Extensions for BGP4)
* 04 <- length
* 00 02 00 01 <- AFI 2, SAFI 1
* 02 <- opt. param. type (capabilities)
* 06 <- length
* 01 <- capability code (MP Extensions for BGP4)
* 04 <- length
* 40 04 00 47 <- AFI 16388, SAFI 71
* 02 <- opt. param. type (capabilities)
* 06 <- length
* 41 <- capability code (AS4 octet support)
* 04 <- length
* 00 00 00 64 <- AS number
*/
@Test
public void testOpenMessage() throws Exception {
final MessageRegistry msgReg = ServiceLoaderBGPExtensionProviderContext.getSingletonInstance().getMessageRegistry();
final Notification o = msgReg.parseMessage(Unpooled.copiedBuffer(inputBytes.get(3)), null);
final Open open = (Open) o;
final Set<BgpTableType> types = Sets.newHashSet();
for (final BgpParameters param : open.getBgpParameters()) {
for (final OptionalCapabilities optCapa : param.getOptionalCapabilities()) {
final CParameters cParam = optCapa.getCParameters();
if (cParam != null && cParam.getAugmentation(CParameters1.class) != null && cParam.getAugmentation(CParameters1.class).getMultiprotocolCapability() != null) {
final MultiprotocolCapability mp = cParam.getAugmentation(CParameters1.class).getMultiprotocolCapability();
final BgpTableType type = new BgpTableTypeImpl(mp.getAfi(), mp.getSafi());
types.add(type);
}
}
}
final Set<BgpTableType> expected = Sets.newHashSet();
expected.add(new BgpTableTypeImpl(Ipv4AddressFamily.class, UnicastSubsequentAddressFamily.class));
expected.add(new BgpTableTypeImpl(Ipv6AddressFamily.class, UnicastSubsequentAddressFamily.class));
expected.add(new BgpTableTypeImpl(LinkstateAddressFamily.class, LinkstateSubsequentAddressFamily.class));
assertEquals(expected, types);
final ByteBuf buffer = Unpooled.buffer();
msgReg.serializeMessage(o, buffer);
assertArrayEquals(inputBytes.get(3), ByteArray.readAllBytes(buffer));
}
Aggregations