bharat saraswal
Committed by Ray Milkey

Test cases renamed and fixed.

Change-Id: I8b8134bbb0300029b83bf0804bdc6d97b7cec43f
......@@ -296,8 +296,7 @@ public class PcepTEObjectVer1 implements PcepTEObject {
tlv = LocalTENodeDescriptorsTLV.read(cb, hLength);
break;
case RemoteTENodeDescriptorsTLV.TYPE:
RemoteTENodeDescriptorsTLV.hLength = hLength;
tlv = RemoteTENodeDescriptorsTLV.read(cb);
tlv = RemoteTENodeDescriptorsTLV.read(cb, hLength);
break;
case TELinkDescriptorsTLV.TYPE:
tlv = TELinkDescriptorsTLV.read(cb, hLength);
......
......@@ -169,7 +169,7 @@ public class LocalTENodeDescriptorsTLV implements PcepValueType {
}
}
hLength = (short) (c.writerIndex() - tlvStartIndex);
c.setShort(tlvLenIndex, hLength);
c.setShort(tlvLenIndex, (hLength - TLV_HEADER_LENGTH));
return c.writerIndex() - tlvStartIndex;
}
......@@ -186,7 +186,7 @@ public class LocalTENodeDescriptorsTLV implements PcepValueType {
// Node Descriptor Sub-TLVs (variable)
LinkedList<PcepValueType> llNodeDescriptorSubTLVs = new LinkedList<PcepValueType>();
ChannelBuffer tempCb = c.readBytes(hLength - TLV_HEADER_LENGTH);
ChannelBuffer tempCb = c.readBytes(hLength);
while (TLV_HEADER_LENGTH <= tempCb.readableBytes()) {
......
......@@ -116,40 +116,38 @@ public class PcepRsvpSpecObjHeader {
/**
* Writes the byte stream of PcepRsvpObjectHeader to channel buffer.
*
* @param bb of type channel buffer
* @param cb of type channel buffer
* @return object length index
*/
public int write(ChannelBuffer bb) {
int objLenIndex = bb.writerIndex();
bb.writeShort(objLen);
bb.writeByte(objClassNum);
bb.writeByte(objClassType);
return bb.writerIndex() - objLenIndex;
public int write(ChannelBuffer cb) {
int objLenIndex = cb.writerIndex();
objLen = 0;
cb.writeShort(objLen);
cb.writeByte(objClassNum);
cb.writeByte(objClassType);
return objLenIndex;
}
/**
* Reads the PcepRsvpObjectHeader.
*
* @param bb of type channel buffer
* @param cb of type channel buffer
* @return PcepRsvpObjectHeader
*/
public static PcepRsvpSpecObjHeader read(ChannelBuffer bb) {
public static PcepRsvpSpecObjHeader read(ChannelBuffer cb) {
byte objClassNum;
byte objClassType;
short objLen;
objLen = bb.readShort();
objClassNum = bb.readByte();
objClassType = bb.readByte();
objLen = cb.readShort();
objClassNum = cb.readByte();
objClassType = cb.readByte();
return new PcepRsvpSpecObjHeader(objLen, objClassNum, objClassType);
}
@Override
public String toString() {
return MoreObjects.toStringHelper(getClass())
.add("ObjectClassNum: " , objClassNum)
.add("ObjectCType: " , objClassType)
.add("ObjectLength: " , objLen)
.toString();
return MoreObjects.toStringHelper(getClass()).add("ObjectClassNum: ", objClassNum)
.add("ObjectCType: ", objClassType).add("ObjectLength: ", objLen).toString();
}
}
......
......@@ -50,7 +50,7 @@ public class RemoteTENodeDescriptorsTLV implements PcepValueType {
protected static final Logger log = LoggerFactory.getLogger(RemoteTENodeDescriptorsTLV.class);
public static final short TYPE = 1003; //TODD:change this TBD9
public static short hLength;
public short hLength;
public static final int TLV_HEADER_LENGTH = 4;
// Node Descriptor Sub-TLVs (variable)
......@@ -172,7 +172,7 @@ public class RemoteTENodeDescriptorsTLV implements PcepValueType {
}
hLength = (short) (c.writerIndex() - tlvStartIndex);
c.setShort(tlvLenIndex, hLength);
c.setShort(tlvLenIndex, (hLength - TLV_HEADER_LENGTH));
return c.writerIndex() - tlvStartIndex;
}
......@@ -184,12 +184,12 @@ public class RemoteTENodeDescriptorsTLV implements PcepValueType {
* @return object of RemoteTENodeDescriptorsTLV
* @throws PcepParseException if mandatory fields are missing
*/
public static PcepValueType read(ChannelBuffer c) throws PcepParseException {
public static PcepValueType read(ChannelBuffer c , short length) throws PcepParseException {
// Node Descriptor Sub-TLVs (variable)
LinkedList<PcepValueType> llRemoteTENodeDescriptorSubTLVs = new LinkedList<PcepValueType>();
ChannelBuffer tempCb = c.readBytes(hLength - TLV_HEADER_LENGTH);
ChannelBuffer tempCb = c.readBytes(length);
while (TLV_HEADER_LENGTH <= tempCb.readableBytes()) {
......
......@@ -104,7 +104,7 @@ public class StatefulRsvpErrorSpecTlv implements PcepValueType {
public static final short TYPE = 21;
public static final int OBJECT_HEADER_LENGTH = 4;
private final short hLength;
private short hLength;
private final PcepRsvpErrorSpec rsvpErrSpecObj;
private final boolean isErrSpceObjSet;
......@@ -113,12 +113,10 @@ public class StatefulRsvpErrorSpecTlv implements PcepValueType {
* Constructor to initialize errSpecObj.
*
* @param rsvpErrSpecObj Rsvp error spec object
* @param hLength length of rsvp error spec object
*/
public StatefulRsvpErrorSpecTlv(PcepRsvpErrorSpec rsvpErrSpecObj, short hLength) {
public StatefulRsvpErrorSpecTlv(PcepRsvpErrorSpec rsvpErrSpecObj) {
this.rsvpErrSpecObj = rsvpErrSpecObj;
this.isErrSpceObjSet = true;
this.hLength = hLength;
}
/**
......@@ -171,7 +169,7 @@ public class StatefulRsvpErrorSpecTlv implements PcepValueType {
&& PcepRsvpUserErrorSpec.CLASS_TYPE == rsvpErrSpecObjHeader.getObjClassType()) {
rsvpErrSpecObj = PcepRsvpUserErrorSpec.read(cb);
}
return rsvpErrSpecObj;
return new StatefulRsvpErrorSpecTlv(rsvpErrSpecObj);
}
@Override
......@@ -196,14 +194,15 @@ public class StatefulRsvpErrorSpecTlv implements PcepValueType {
int iStartIndex = c.writerIndex();
c.writeShort(TYPE);
int tlvLenIndex = c.writerIndex();
hLength = 0;
c.writeShort(hLength);
if (isErrSpceObjSet) {
rsvpErrSpecObj.write(c);
}
short tlvLen = (short) (c.writerIndex() - iStartIndex + 4);
c.setShort(tlvLenIndex, tlvLen);
hLength = (short) (c.writerIndex() - iStartIndex);
c.setShort(tlvLenIndex, (hLength - OBJECT_HEADER_LENGTH));
return tlvLen;
return c.writerIndex() - iStartIndex;
}
@Override
......
......@@ -63,7 +63,6 @@ public class TELinkAttributesTlv implements PcepValueType {
*/
public TELinkAttributesTlv(LinkedList<PcepValueType> llLinkAttributesSubTLVs) {
this.llLinkAttributesSubTLVs = llLinkAttributesSubTLVs;
}
/**
......@@ -171,7 +170,7 @@ public class TELinkAttributesTlv implements PcepValueType {
}
hLength = (short) (c.writerIndex() - tlvStartIndex);
c.setShort(tlvLenIndex, hLength);
c.setShort(tlvLenIndex, (hLength - TLV_HEADER_LENGTH));
return c.writerIndex() - tlvStartIndex;
}
......@@ -189,7 +188,7 @@ public class TELinkAttributesTlv implements PcepValueType {
// Node Descriptor Sub-TLVs (variable)
LinkedList<PcepValueType> llLinkAttributesSubTLVs = new LinkedList<PcepValueType>();
ChannelBuffer tempCb = c.readBytes(hLength - TLV_HEADER_LENGTH);
ChannelBuffer tempCb = c.readBytes(hLength);
while (TLV_HEADER_LENGTH <= tempCb.readableBytes()) {
......
......@@ -167,7 +167,7 @@ public class TELinkDescriptorsTLV implements PcepValueType {
}
hLength = (short) (c.writerIndex() - tlvStartIndex);
c.setShort(tlvLenIndex, hLength);
c.setShort(tlvLenIndex, (hLength - TLV_HEADER_LENGTH));
return c.writerIndex() - tlvStartIndex;
}
......@@ -185,7 +185,7 @@ public class TELinkDescriptorsTLV implements PcepValueType {
// Node Descriptor Sub-TLVs (variable)
LinkedList<PcepValueType> llLinkDescriptorsSubTLVs = new LinkedList<PcepValueType>();
ChannelBuffer tempCb = c.readBytes(length - TLV_HEADER_LENGTH);
ChannelBuffer tempCb = c.readBytes(length);
while (TLV_HEADER_LENGTH <= tempCb.readableBytes()) {
......
......@@ -167,7 +167,7 @@ public class TENodeAttributesTlv implements PcepValueType {
}
hLength = (short) (c.writerIndex() - tlvStartIndex);
c.setShort(tlvLenIndex, hLength);
c.setShort(tlvLenIndex, (hLength - TLV_HEADER_LENGTH));
return c.writerIndex() - tlvStartIndex;
}
......@@ -185,7 +185,7 @@ public class TENodeAttributesTlv implements PcepValueType {
// Node Descriptor Sub-TLVs (variable)
LinkedList<PcepValueType> llNodeAttributesSubTLVs = new LinkedList<PcepValueType>();
ChannelBuffer tempCb = c.readBytes(hLength - TLV_HEADER_LENGTH);
ChannelBuffer tempCb = c.readBytes(hLength);
while (TLV_HEADER_LENGTH <= tempCb.readableBytes()) {
PcepValueType tlv;
......
......@@ -27,7 +27,7 @@ import org.onosproject.pcepio.protocol.PcepMessage;
import org.onosproject.pcepio.protocol.PcepMessageReader;
import org.onosproject.pcepio.protocol.PcepReportMsg;
public class PcepReportMsgTest2 {
public class PcepReportMsgExtTest {
/**
* This test case checks forSRP Object,LSP Object(symbolic path tlv),ERO Object
......@@ -39,17 +39,17 @@ public class PcepReportMsgTest2 {
byte[] reportMsg = new byte[] {0x20, 0x0a, 0x00, (byte) 0x98,
0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP object
0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, (byte) 0x83, //LSP object
0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //symbolic path tlv
0x07, 0x10, 0x00, 0x14, //ERO Object
(byte) 0x81, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00,
(byte) 0x81, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00,
0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00,
0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00,
0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP object
0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, (byte) 0x83, //LSP object
0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //symbolic path tlv
0x07, 0x10, 0x00, 0x14, //ERO object
(byte) 0x81, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00,
(byte) 0x81, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00,
0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00,
0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00,
0x08, 0x10, 0x00, 0x34, 0x01, 0x08, 0x11, 0x01, //RRO object
0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x06, 0x06,
......@@ -86,17 +86,17 @@ public class PcepReportMsgTest2 {
byte[] reportMsg = new byte[] {0x20, 0x0a, 0x00, (byte) 0x64,
0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP object
0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, (byte) 0x83, //LSP object
0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //symbolic path tlv
0x07, 0x10, 0x00, 0x14, //ERO object
(byte) 0x81, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00,
(byte) 0x81, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00,
0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00,
0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00,
0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP object
0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, (byte) 0x83, //LSP object
0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //symbolic path tlv
0x07, 0x10, 0x00, 0x14, //ERO object
(byte) 0x81, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00,
(byte) 0x81, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00};
0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00,
0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00};
byte[] testReportMsg = {0};
ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
......@@ -127,19 +127,19 @@ public class PcepReportMsgTest2 {
byte[] reportMsg = new byte[] {0x20, 0x0a, 0x00, (byte) 0x8c,
0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP object
0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, (byte) 0x83, //LSP object
0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //symbolic path tlv
0x07, 0x10, 0x00, 0x14, //ERO object
(byte) 0x81, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00,
(byte) 0x81, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00,
0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00,
0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00,
0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP object
0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, (byte) 0x83, //LSP object
0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //symbolic path tlv
0x07, 0x10, 0x00, 0x14, //ERO object
(byte) 0x81, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00,
(byte) 0x81, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00,
0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00,
0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00,
0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, //LSPA object
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
......@@ -173,21 +173,21 @@ public class PcepReportMsgTest2 {
byte[] reportMsg = new byte[] {0x20, 0x0a, 0x00, (byte) 0xE8,
0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP object
0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, (byte) 0x83, //LSP object
0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //symbolic path tlv
0x07, 0x10, 0x00, 0x14, //ERO object
(byte) 0x81, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00,
(byte) 0x81, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00,
0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00,
0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00,
0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20, //Metric object
0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP object
0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, (byte) 0x83, //LSP object
0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //symbolic path tlv
0x07, 0x10, 0x00, 0x14, //ERO object
(byte) 0x81, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00,
(byte) 0x81, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00,
0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00,
0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00,
0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
......