case UNRESERVED_BANDWIDTH:
final List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev150210.link.state.UnreservedBandwidth> unreservedBandwidth = new ArrayList<>(UNRESERVED_BW_COUNT);
for (int i = 0; i < UNRESERVED_BW_COUNT; i++) {
- final ByteBuf v = value.slice(value.readerIndex(), BANDWIDTH_LENGTH);
+ final ByteBuf v = value.readSlice(BANDWIDTH_LENGTH);
unreservedBandwidth.add(new UnreservedBandwidthBuilder().setBandwidth(new Bandwidth(ByteArray.readAllBytes(v))).setPriority((short) i).build());
- value.skipBytes(BANDWIDTH_LENGTH);
}
builder.setUnreservedBandwidth(unreservedBandwidth);
LOG.debug("Parsed Unreserved Bandwidth {}", builder.getUnreservedBandwidth());
while (buffer.isReadable()) {
final int type = buffer.readUnsignedShort();
final int length = buffer.readUnsignedShort();
- final ByteBuf value = buffer.slice(buffer.readerIndex(), length);
+ final ByteBuf value = buffer.readSlice(length);
map.put(type, value);
- buffer.skipBytes(length);
}
final LinkstatePathAttributeBuilder builder = new LinkstatePathAttributeBuilder();
while (buffer.isReadable()) {
final int type = buffer.readUnsignedShort();
final int length = buffer.readUnsignedShort();
- final ByteBuf value = buffer.slice(buffer.readerIndex(), length);
+ final ByteBuf value = buffer.readSlice(length);
LOG.trace("Parsing Link Descriptor: {}", ByteBufUtil.hexDump(value));
switch (type) {
case LINK_LR_IDENTIFIERS:
default:
throw new BGPParsingException("Link Descriptor not recognized, type: " + type);
}
- buffer.skipBytes(length);
}
LOG.trace("Finished parsing Link descriptors.");
return builder.build();
final int length = buffer.readUnsignedShort();
final NodeIdentifier remote = null;
if (type == REMOTE_NODE_DESCRIPTORS) {
- builder.setRemoteNodeDescriptors((RemoteNodeDescriptors) NodeNlriParser.parseNodeDescriptors(buffer.slice(buffer.readerIndex(), length), false));
- buffer.skipBytes(length);
+ builder.setRemoteNodeDescriptors((RemoteNodeDescriptors) NodeNlriParser.parseNodeDescriptors(buffer.readSlice(length), false));
}
builder.setLinkDescriptors(LinkNlriParser.parseLinkDescriptors(buffer.slice()));
return remote;
final int localtype = nlri.readUnsignedShort();
locallength = nlri.readUnsignedShort();
if (localtype == LOCAL_NODE_DESCRIPTORS) {
- localDescriptor = NodeNlriParser.parseNodeDescriptors(nlri.slice(nlri.readerIndex(), locallength), true);
+ localDescriptor = NodeNlriParser.parseNodeDescriptors(nlri.readSlice(locallength), true);
}
- nlri.skipBytes(locallength);
builder.setLocalNodeDescriptors((LocalNodeDescriptors) localDescriptor);
final int restLength = length - (isVpn ? ROUTE_DISTINGUISHER_LENGTH : 0) - PROTOCOL_ID_LENGTH - IDENTIFIER_LENGTH
- TYPE_LENGTH - LENGTH_SIZE - locallength;
LOG.trace("Restlength {}", restLength);
- final ByteBuf rest = nlri.slice(nlri.readerIndex(), restLength);
+ final ByteBuf rest = nlri.readSlice(restLength);
switch (type) {
case Link:
parseLink(builder, rest);
default:
break;
}
- nlri.skipBytes(restLength);
dests.add(builder.build());
}
return dests;
while (buffer.isReadable()) {
final int type = buffer.readUnsignedShort();
final int length = buffer.readUnsignedShort();
- final ByteBuf value = buffer.slice(buffer.readerIndex(), length);
+ final ByteBuf value = buffer.readSlice(length);
if (LOG.isTraceEnabled()) {
LOG.trace("Parsing Node Descriptor: {}", ByteBufUtil.hexDump(value));
}
default:
throw new BGPParsingException("Node Descriptor not recognized, type: " + type);
}
- buffer.skipBytes(length);
}
LOG.trace("Finished parsing Node descriptors.");
return (local) ? new LocalNodeDescriptorsBuilder().setAsNumber(asnumber).setDomainId(bgpId).setAreaId(ai).setCRouterIdentifier(
while (buffer.isReadable()) {
final int type = buffer.readUnsignedShort();
final int length = buffer.readUnsignedShort();
- final ByteBuf value = buffer.slice(buffer.readerIndex(), length);
+ final ByteBuf value = buffer.readSlice(length);
if (LOG.isTraceEnabled()) {
LOG.trace("Parsing Prefix Descriptor: {}", ByteBufUtil.hexDump(value));
}
default:
throw new BGPParsingException("Prefix Descriptor not recognized, type: " + type);
}
- buffer.skipBytes(length);
}
LOG.debug("Finished parsing Prefix descriptors.");
return builder.build();
final List<BgpParameters> optParams = new ArrayList<>();
if (optLength > 0) {
- fillParams(body.slice(body.readerIndex(), optLength), optParams);
+ fillParams(body.slice(), optParams);
}
LOG.debug("BGP Open message was parsed: AS = {}, holdTimer = {}, bgpId = {}, optParams = {}", as, holdTime, bgpId, optParams);
return new OpenBuilder().setMyAsNumber(as.getValue().intValue()).setHoldTimer(holdTime).setBgpIdentifier(bgpId).setBgpParameters(
}
final int paramType = buffer.readUnsignedByte();
final int paramLength = buffer.readUnsignedByte();
- final ByteBuf paramBody = buffer.slice(buffer.readerIndex(), paramLength);
+ final ByteBuf paramBody = buffer.readSlice(paramLength);
final BgpParameters param;
try {
} else {
LOG.debug("Ignoring BGP Parameter type: {}", paramType);
}
- buffer.skipBytes(paramLength);
}
LOG.trace("Parsed BGP parameters: {}", Arrays.toString(params.toArray()));
}
}
if (totalPathAttrLength > 0) {
try {
- final PathAttributes pathAttributes = this.reg.parseAttributes(buffer.slice(buffer.readerIndex(), totalPathAttrLength));
- buffer.skipBytes(totalPathAttrLength);
+ final PathAttributes pathAttributes = this.reg.parseAttributes(buffer.readSlice(totalPathAttrLength));
eventBuilder.setPathAttributes(pathAttributes);
} catch (final BGPParsingException | RuntimeException e) {
// Catch everything else and turn it into a BGPDocumentedException
private OptionalCapabilities parseOptionalCapability(final ByteBuf buffer) throws BGPDocumentedException, BGPParsingException {
final int capCode = buffer.readUnsignedByte();
final int capLength = buffer.readUnsignedByte();
- final ByteBuf paramBody = buffer.slice(buffer.readerIndex(), capLength);
- buffer.skipBytes(capLength);
+ final ByteBuf paramBody = buffer.readSlice(capLength);
final CParameters ret = this.reg.parseCapability(capCode, paramBody);
if (ret == null) {
LOG.debug("Ignoring unsupported capability {}", capCode);
}
@Override
- public void serializeParameter(final BgpParameters parameter, ByteBuf byteAggregator) {
+ public void serializeParameter(final BgpParameters parameter, final ByteBuf byteAggregator) {
if (parameter.getOptionalCapabilities() != null && !parameter.getOptionalCapabilities().isEmpty()) {
LOG.trace("Started serializing BGP Capability: {}", parameter.getOptionalCapabilities());
final ByteBuf buffer = Unpooled.buffer();
final int count = UnsignedBytes.toInt(buffer.readByte());
if (segmentType == SegmentType.AS_SEQUENCE) {
- final List<AsSequence> numbers = AsPathSegmentParser.parseAsSequence(refCache, count, buffer.slice(buffer.readerIndex(),
- count * AsPathSegmentParser.AS_NUMBER_LENGTH));
+ final List<AsSequence> numbers = AsPathSegmentParser.parseAsSequence(refCache, count, buffer.readSlice(count * AsPathSegmentParser.AS_NUMBER_LENGTH));
ases.add(new SegmentsBuilder().setCSegment(
new AListCaseBuilder().setAList(new AListBuilder().setAsSequence(numbers).build()).build()).build());
isSequence = true;
} else {
- final List<AsNumber> list = AsPathSegmentParser.parseAsSet(refCache, count, buffer.slice(buffer.readerIndex(), count
- * AsPathSegmentParser.AS_NUMBER_LENGTH));
+ final List<AsNumber> list = AsPathSegmentParser.parseAsSet(refCache, count, buffer.readSlice(count * AsPathSegmentParser.AS_NUMBER_LENGTH));
ases.add(new SegmentsBuilder().setCSegment(new ASetCaseBuilder().setASet(new ASetBuilder().setAsSet(list).build()).build()).build());
-
}
- buffer.skipBytes(count * AsPathSegmentParser.AS_NUMBER_LENGTH);
}
if (!isSequence) {
throw new BGPDocumentedException("AS_SEQUENCE must be present in AS_PATH attribute.", BGPError.AS_PATH_MALFORMED);
public void parseAttribute(final ByteBuf buffer, final PathAttributesBuilder builder) throws BGPDocumentedException {
final List<Communities> set = Lists.newArrayList();
while (buffer.isReadable()) {
- set.add((Communities) parseCommunity(this.refCache, buffer.slice(buffer.readerIndex(), COMMUNITY_LENGTH)));
- buffer.skipBytes(COMMUNITY_LENGTH);
+ set.add((Communities) parseCommunity(this.refCache, buffer.readSlice(COMMUNITY_LENGTH)));
}
builder.setCommunities(set);
}
while (buffer.isReadable()) {
final ExtendedCommunitiesBuilder exBuilder = new ExtendedCommunitiesBuilder();
parseHeader(exBuilder, buffer);
- final ExtendedCommunities comm = parseExtendedCommunity(this.refCache, exBuilder, buffer.slice(buffer.readerIndex(), EXTENDED_COMMUNITY_LENGTH));
- buffer.skipBytes(EXTENDED_COMMUNITY_LENGTH);
+ final ExtendedCommunities comm = parseExtendedCommunity(this.refCache, exBuilder, buffer.readSlice(EXTENDED_COMMUNITY_LENGTH));
set.add(comm);
}
builder.setExtendedCommunities(set);
import static org.hamcrest.CoreMatchers.containsString;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
+
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import io.netty.buffer.ByteBuf;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130919.Open;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130919.OpenBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130919.ProtocolVersion;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130919.Update;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130919.open.BgpParameters;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130919.open.BgpParametersBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130919.open.bgp.parameters.OptionalCapabilities;
@Test
public void testParseUpdMsgWithUnrecognizedAttribute() throws BGPDocumentedException, BGPParsingException {
- final Update updMsg = (Update) reg.parseMessage(Unpooled.copiedBuffer(updMsgWithUnrecognizedAttribute));
- assertNotNull(updMsg.getPathAttributes());
+ try {
+ reg.parseMessage(Unpooled.copiedBuffer(updMsgWithUnrecognizedAttribute));
+ fail("Exception should have occured.");
+ } catch (final BGPDocumentedException e) {
+ assertEquals("Well known attribute not recognized.", e.getMessage());
+ assertEquals(BGPError.WELL_KNOWN_ATTR_NOT_RECOGNIZED, e.getError());
+ return;
+ }
+ fail();
}
}
+ "; Expected: " + (messageLength - MessageUtil.COMMON_HEADER_LENGTH) + ". ");
}
- final ByteBuf msgBody = buffer.slice(buffer.readerIndex(), messageLength - MessageUtil.COMMON_HEADER_LENGTH);
+ final ByteBuf msgBody = buffer.readSlice(messageLength - MessageUtil.COMMON_HEADER_LENGTH);
- Notification msg = null;
- try {
- msg = parseBody(messageType, msgBody, messageLength);
- } finally {
- // Always reads body bytes
- buffer.skipBytes(messageLength - MessageUtil.COMMON_HEADER_LENGTH);
- }
+ final Notification msg = parseBody(messageType, msgBody, messageLength);
if (msg == null) {
throw new BGPDocumentedException("Unhandled message type " + messageType, BGPError.BAD_MSG_TYPE, new byte[] { typeBytes });
}
LOG.warn("Ignoring unrecognized attribute type {}. Some data might be missing from the output.", type);
}
} else {
- attributes.put(type, new RawAttribute(parser, buffer.slice(buffer.readerIndex(), len)));
+ attributes.put(type, new RawAttribute(parser, buffer.readSlice(len)));
}
} else {
LOG.debug("Ignoring duplicate attribute type {}", type);
}
- buffer.skipBytes(len);
}
@Override
import com.google.common.base.Preconditions;
import com.google.common.collect.Iterables;
import com.google.common.primitives.UnsignedBytes;
-
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
-
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
-
import org.opendaylight.bgp.concepts.NextHopUtil;
import org.opendaylight.protocol.bgp.parser.BGPParsingException;
import org.opendaylight.protocol.bgp.parser.BgpTableTypeImpl;
}
@Override
- public void serializeMpReach(MpReachNlri mpReachNlri, ByteBuf byteAggregator) {
+ public void serializeMpReach(final MpReachNlri mpReachNlri, final ByteBuf byteAggregator) {
byteAggregator.writeShort(this.afiReg.numberForClass(mpReachNlri.getAfi()));
byteAggregator.writeByte(this.safiReg.numberForClass(mpReachNlri.getSafi()));
}
@Override
- public void serializeMpUnReach(MpUnreachNlri mpUnreachNlri, ByteBuf byteAggregator) {
+ public void serializeMpUnReach(final MpUnreachNlri mpUnreachNlri, final ByteBuf byteAggregator) {
byteAggregator.writeShort(this.afiReg.numberForClass(mpUnreachNlri.getAfi()));
byteAggregator.writeByte(this.safiReg.numberForClass(mpUnreachNlri.getSafi()));
}
final NlriParser parser = this.handlers.get(createKey(builder.getAfi(), builder.getSafi()));
final int nextHopLength = UnsignedBytes.toInt(buffer.readByte());
- builder.setCNextHop(NextHopUtil.parseNextHop(buffer.slice(buffer.readerIndex(), nextHopLength)));
- buffer.skipBytes(nextHopLength + RESERVED);
+ builder.setCNextHop(NextHopUtil.parseNextHop(buffer.readSlice(nextHopLength)));
+ buffer.skipBytes(RESERVED);
final ByteBuf nlri = buffer.slice();
parser.parseNlri(nlri, builder);
+ buffer.readableBytes());
}
LOG.debug("Attempt to parse subobject from bytes: {}", ByteBufUtil.hexDump(buffer));
- final Subobject sub = this.subobjReg.parseSubobject(type, buffer.slice(buffer.readerIndex(), length), loose);
+ final Subobject sub = this.subobjReg.parseSubobject(type, buffer.readSlice(length), loose);
if (sub == null) {
LOG.warn("Unknown subobject type: {}. Ignoring subobject.", type);
} else {
LOG.debug("Subobject was parsed. {}", sub);
subs.add(sub);
}
- buffer.readerIndex(buffer.readerIndex() + length);
}
return subs;
}
Preconditions.checkArgument(buffer != null && buffer.isReadable(), "Array of bytes is mandatory. Can't be null or empty.");
final List<Subobject> subs = new ArrayList<>();
while (buffer.isReadable()) {
- int type = UnsignedBytes.toInt(buffer.readByte());
- int length = UnsignedBytes.toInt(buffer.readByte()) - HEADER_LENGTH;
+ final int type = UnsignedBytes.toInt(buffer.readByte());
+ final int length = UnsignedBytes.toInt(buffer.readByte()) - HEADER_LENGTH;
if (length > buffer.readableBytes()) {
throw new PCEPDeserializerException("Wrong length specified. Passed: " + length + "; Expected: <= "
+ buffer.readableBytes());
}
LOG.debug("Attempt to parse subobject from bytes: {}", ByteBufUtil.hexDump(buffer));
- final Subobject sub = this.subobjReg.parseSubobject(type, buffer.slice(buffer.readerIndex(), length));
+ final Subobject sub = this.subobjReg.parseSubobject(type, buffer.readSlice(length));
if (sub == null) {
LOG.warn("Unknown subobject type: {}. Ignoring subobject.", type);
} else {
LOG.debug("Subobject was parsed. {}", sub);
subs.add(sub);
}
- buffer.readerIndex(buffer.readerIndex() + length);
}
return subs;
}
import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeUnsignedInt;
import com.google.common.base.Preconditions;
-
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
-
import org.opendaylight.protocol.pcep.spi.EnterpriseSpecificInformationParser;
import org.opendaylight.protocol.pcep.spi.ObjectParser;
import org.opendaylight.protocol.pcep.spi.ObjectSerializer;
public final Object parseObject(final ObjectHeader header, final ByteBuf buffer) throws PCEPDeserializerException {
Preconditions.checkArgument(buffer != null && buffer.isReadable(), "Array of bytes is mandatory. Can't be null or empty.");
final VendorInformationObjectBuilder builder = new VendorInformationObjectBuilder();
- buffer.readUnsignedInt();
builder.setEnterpriseNumber(new EnterpriseNumber(getEnterpriseNumber()));
builder.setEnterpriseSpecificInformation(parseEnterpriseSpecificInformation(buffer));
return builder.build();
+ buffer.readableBytes());
}
LOG.debug("Attempt to parse subobject from bytes: {}", ByteBufUtil.hexDump(buffer));
- final Subobject sub = this.subobjReg.parseSubobject(type, buffer.slice(buffer.readerIndex(), length), mandatory);
+ final Subobject sub = this.subobjReg.parseSubobject(type, buffer.readSlice(length), mandatory);
if (sub == null) {
LOG.warn("Unknown subobject type: {}. Ignoring subobject.", type);
} else {
LOG.debug("Subobject was parsed. {}", sub);
subs.add(sub);
}
- buffer.readerIndex(buffer.readerIndex() + length);
}
return subs;
}
throw new PCEPDeserializerException("Wrong length specified. Passed: " + length + "; Expected: <= "
+ buffer.readableBytes());
}
- subs.add(this.registry.parseSubobject(type, buffer.slice(buffer.readerIndex(), length), mandatory));
- buffer.readerIndex(buffer.readerIndex() + length);
+ subs.add(this.registry.parseSubobject(type, buffer.readSlice(length), mandatory));
}
return subs;
}
final VendorInformationObject viObj = new VendorInformationObjectBuilder().setEnterpriseNumber(new EnterpriseNumber(0L))
.setEnterpriseSpecificInformation(esInfo).build();
final ByteBuf result = Unpooled.wrappedBuffer(viObjBytes);
-
- assertEquals(viObj, parser.parseObject(new ObjectHeaderImpl(false, false), result.slice(4, result.readableBytes() - 4)));
+ result.readerIndex(8);
+ final VendorInformationObject o = (VendorInformationObject) parser.parseObject(new ObjectHeaderImpl(false, false), result.readSlice(result.readableBytes()));
+ assertEquals(viObj, o);
final ByteBuf buf = Unpooled.buffer(viObjBytes.length);
parser.serializeObject(viObj, buf);
+ objLength + ".");
}
// copy bytes for deeper parsing
- final ByteBuf bytesToPass = bytes.slice(bytes.readerIndex(), objLength - COMMON_OBJECT_HEADER_LENGTH);
+ final ByteBuf bytesToPass = bytes.readSlice(objLength - COMMON_OBJECT_HEADER_LENGTH);
final ObjectHeader header = new ObjectHeaderImpl(flags.get(P_FLAG_OFFSET), flags.get(I_FLAG_OFFSET));
if (VendorInformationUtil.isVendorInformationObject(objClass, objType)) {
Preconditions.checkState(this.viRegistry != null);
- final EnterpriseNumber enterpriseNumber = new EnterpriseNumber(bytes.getUnsignedInt(bytes.readerIndex()));
+ final EnterpriseNumber enterpriseNumber = new EnterpriseNumber(bytesToPass.readUnsignedInt());
final Optional<? extends Object> obj = this.viRegistry.parseVendorInformationObject(enterpriseNumber, header, bytesToPass);
if (obj.isPresent()) {
objs.add(obj.get());
objs.add(o);
}
}
-
- bytes.readerIndex(bytes.readerIndex() + objLength - COMMON_OBJECT_HEADER_LENGTH);
}
return objs;
}
final List<VendorInformationTlv> viTlvs = Lists.newArrayList();
while (bytes.isReadable()) {
- int type = bytes.readUnsignedShort();
- int length = bytes.readUnsignedShort();
+ final int type = bytes.readUnsignedShort();
+ final int length = bytes.readUnsignedShort();
if (length > bytes.readableBytes()) {
throw new PCEPDeserializerException("Wrong length specified. Passed: " + length + "; Expected: <= " + bytes.readableBytes()
+ ".");
}
- final ByteBuf tlvBytes = bytes.slice(bytes.readerIndex(), length);
+ final ByteBuf tlvBytes = bytes.readSlice(length);
LOG.trace("Parsing PCEP TLV : {}", ByteBufUtil.hexDump(tlvBytes));
if (VendorInformationUtil.isVendorInformationTlv(type)) {
addTlv(builder, tlv);
}
}
- bytes.skipBytes(length + TlvUtil.getPadding(TlvUtil.HEADER_SIZE + length, TlvUtil.PADDED_TO));
+ bytes.skipBytes(TlvUtil.getPadding(TlvUtil.HEADER_SIZE + length, TlvUtil.PADDED_TO));
}
addVendorInformationTlvs(builder, viTlvs);
}
private class Abs extends AbstractMessageParser {
- protected Abs(ObjectRegistry registry) {
+ protected Abs(final ObjectRegistry registry) {
super(registry);
}
- protected Abs(ObjectRegistry registry, VendorInformationObjectRegistry viRegistry) {
+ protected Abs(final ObjectRegistry registry, final VendorInformationObjectRegistry viRegistry) {
super(registry, viRegistry);
}
@Override
- public void serializeMessage(Message message, ByteBuf buffer) {
+ public void serializeMessage(final Message message, final ByteBuf buffer) {
}
@Override
- protected Message validate(List<Object> objects, List<Message> errors) throws PCEPDeserializerException {
+ protected Message validate(final List<Object> objects, final List<Message> errors) throws PCEPDeserializerException {
if (objects.get(0) instanceof VendorInformationObject) {
final RepliesBuilder repsBuilder = new RepliesBuilder();
repsBuilder.setVendorInformationObject(addVendorInformationObjects(objects));
this.object = new ErrorObjectBuilder().setType((short) 1).setValue((short) 1).build();
this.viObject = new VendorInformationObjectBuilder().setEnterpriseNumber(EN).build();
Mockito.doNothing().when(this.viRegistry).serializeVendorInformationObject(Mockito.any(VendorInformationObject.class), Mockito.any(ByteBuf.class));
- Mockito.doReturn(Optional.of(this.viObject)).when(this.viRegistry).parseVendorInformationObject(EN, new ObjectHeaderImpl(true, true), Unpooled.wrappedBuffer(new byte[] { 0, 0, 0, 0 }));
+ Mockito.doReturn(Optional.of(this.viObject)).when(this.viRegistry).parseVendorInformationObject(Mockito.eq(EN), Mockito.eq(new ObjectHeaderImpl(true, true)), Mockito.any(ByteBuf.class));
Mockito.doNothing().when(this.registry).serializeObject(Mockito.any(Object.class), Mockito.any(ByteBuf.class));
Mockito.doReturn(this.object).when(this.registry).parseObject(13, 1, new ObjectHeaderImpl(true, true), Unpooled.wrappedBuffer(new byte[] { 0, 0, 1, 1 }));
}
@Test
public void testParseObjects() throws PCEPDeserializerException {
- Abs a = new Abs(this.registry);
- ByteBuf buffer = Unpooled.buffer();
+ final Abs a = new Abs(this.registry);
+ final ByteBuf buffer = Unpooled.buffer();
a.serializeObject(this.object, buffer);
Mockito.verify(this.registry, Mockito.only()).serializeObject(Mockito.any(Object.class), Mockito.any(ByteBuf.class));
- Message b = a.parseMessage(Unpooled.wrappedBuffer(new byte[] {0x0D, 0x13, 0, 0x08, 0, 0, 1, 1 }), Collections.<Message> emptyList());
+ final Message b = a.parseMessage(Unpooled.wrappedBuffer(new byte[] {0x0D, 0x13, 0, 0x08, 0, 0, 1, 1 }), Collections.<Message> emptyList());
assertEquals(this.object, ((Pcerr) b).getPcerrMessage().getErrors().get(0).getErrorObject());
}
final Abs parser = new Abs(this.registry, this.viRegistry);
final ByteBuf buffer = Unpooled.buffer();
- parser.serializeVendorInformationObjects(Lists.newArrayList(viObject), buffer);
+ parser.serializeVendorInformationObjects(Lists.newArrayList(this.viObject), buffer);
Mockito.verify(this.viRegistry, Mockito.only()).serializeVendorInformationObject(Mockito.any(VendorInformationObject.class), Mockito.any(ByteBuf.class));
final Message msg = parser.parseMessage(Unpooled.wrappedBuffer(new byte[] {0x22, 0x13, 0x00, 0x08, 0, 0, 0, 0 }), Collections.<Message> emptyList());