Phaneendra Manda
Committed by Ray Milkey

UT for PcepErr msg updated with assertThat

Change-Id: Ib7a3a58a22e2e998123c6772f6b518eda40c7045
......@@ -18,7 +18,6 @@ package org.onosproject.pcepio;
import org.jboss.netty.buffer.ChannelBuffer;
import org.jboss.netty.buffer.ChannelBuffers;
import org.junit.Assert;
import org.junit.Test;
import org.onosproject.pcepio.exceptions.PcepParseException;
import org.onosproject.pcepio.protocol.PcepErrorMsg;
......@@ -26,6 +25,10 @@ import org.onosproject.pcepio.protocol.PcepFactories;
import org.onosproject.pcepio.protocol.PcepMessage;
import org.onosproject.pcepio.protocol.PcepMessageReader;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.Is.is;
import static org.hamcrest.core.IsSame.sameInstance;
/**
* Test cases for PCEP ERROR Message.
*/
......@@ -36,13 +39,11 @@ public class PcepErrorMsgTest {
* PCEP-ERROR Object, OPEN Object (STATEFUL-PCE-CAPABILITY, GMPLS-CAPABILITY-TLV,
* PCECC-CAPABILITY-TLV, TED Capability TLV)
* in PcepErrorMsg message.
*
* @throws PcepParseException while parsing PCEP message
*/
@Test
public void errorMessageTest1() throws PcepParseException {
byte[] errorMsg = new byte[] {0x20, 0x06, 0x00, 0x34, // common header
byte[] errorMsg = new byte[]{0x20, 0x06, 0x00, 0x34, // common header
0x0D, 0x10, 0x00, 0x08, // PCERR Object Header
0x00, 0x00, 0x01, 0x01, 0x01, 0x10, 0x00, 0x28, // OPEN object header
0x20, 0x05, 0x1E, 0x01, // OPEN object
......@@ -50,7 +51,7 @@ public class PcepErrorMsgTest {
0x00, 0x00, 0x00, 0x05, 0x00, 0x0E, 0x00, 0x04, // GMPLS-CAPABILITY-TLV
0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, // PCECC-CAPABILITY-TLV
0x00, 0x00, 0x00, 0x03, 0x00, (byte) 0x84, 0x00, 0x04, // TED Capability TLV
0x00, 0x00, 0x00, 0x00 };
0x00, 0x00, 0x00, 0x00};
ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
buffer.writeBytes(errorMsg);
......@@ -60,16 +61,16 @@ public class PcepErrorMsgTest {
message = reader.readFrom(buffer);
byte[] testErrorMsg = {0 };
byte[] testErrorMsg = {0};
ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
Assert.assertTrue("PcepMessage is not instance of PcepErrorMsg", message instanceof PcepErrorMsg);
assertThat(message, sameInstance((PcepErrorMsg) message));
message.writeTo(buf);
int iReadLen = buf.writerIndex() - 0;
int iReadLen = buf.writerIndex();
testErrorMsg = new byte[iReadLen];
buf.readBytes(testErrorMsg, 0, iReadLen);
Assert.assertArrayEquals("PcepErrorMsg messages are not equal", errorMsg, testErrorMsg);
assertThat(testErrorMsg, is(errorMsg));
}
/**
......@@ -77,13 +78,11 @@ public class PcepErrorMsgTest {
* PCEP-ERROR Object, PCEP-ERROR Object, OPEN Object (STATEFUL-PCE-CAPABILITY, GMPLS-CAPABILITY-TLV,
* PCECC-CAPABILITY-TLV, TED Capability TLV)
* in PcepErrorMsg message.
*
* @throws PcepParseException while parsing PCEP message
*/
@Test
public void errorMessageTest2() throws PcepParseException {
byte[] errorMsg = new byte[] {0x20, 0x06, 0x00, 0x3C, // common header
byte[] errorMsg = new byte[]{0x20, 0x06, 0x00, 0x3C, // common header
0x0D, 0x10, 0x00, 0x08, // PCERR Object Header
0x00, 0x00, 0x01, 0x01, 0x0D, 0x10, 0x00, 0x08, // PCERR Object Header
0x00, 0x00, 0x01, 0x03, 0x01, 0x10, 0x00, 0x28, // OPEN object header
......@@ -92,7 +91,7 @@ public class PcepErrorMsgTest {
0x00, 0x00, 0x00, 0x05, 0x00, 0x0E, 0x00, 0x04, // GMPLS-CAPABILITY-TLV
0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, // PCECC-CAPABILITY-TLV
0x00, 0x00, 0x00, 0x03, 0x00, (byte) 0x84, 0x00, 0x04, // TED Capability TLV
0x00, 0x00, 0x00, 0x00 };
0x00, 0x00, 0x00, 0x00};
ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
buffer.writeBytes(errorMsg);
......@@ -102,30 +101,27 @@ public class PcepErrorMsgTest {
message = reader.readFrom(buffer);
byte[] testErrorMsg = {0 };
byte[] testErrorMsg = {0};
ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
Assert.assertTrue("PcepMessage is not instance of PcepErrorMsg", message instanceof PcepErrorMsg);
assertThat(message, sameInstance((PcepErrorMsg) message));
message.writeTo(buf);
int iReadLen = buf.writerIndex() - 0;
int iReadLen = buf.writerIndex();
testErrorMsg = new byte[iReadLen];
buf.readBytes(testErrorMsg, 0, iReadLen);
Assert.assertArrayEquals("PcepErrorMsg messages are not equal", errorMsg, testErrorMsg);
assertThat(testErrorMsg, is(errorMsg));
}
/**
* This test case checks for
* PCEP-ERROR Object, PCEP-ERROR Object, OPEN Object (STATEFUL-PCE-CAPABILITY, GMPLS-CAPABILITY-TLV,
* PCEP-ERROR Object, PCEP-ERROR Object, OPEN Object (STATEFUL-PCE-CAPABILITY, GMPLS-CAPABILITY-TLV,
* PCECC-CAPABILITY-TLV)
* in PcepErrorMsg message.
*
* @throws PcepParseException while parsing PCEP message
*/
@Test
public void errorMessageTest3() throws PcepParseException {
byte[] errorMsg = new byte[] {0x20, 0x06, 0x00, 0x34, // common header
byte[] errorMsg = new byte[]{0x20, 0x06, 0x00, 0x34, // common header
0x0D, 0x10, 0x00, 0x08, // PCERR Object Header
0x00, 0x00, 0x01, 0x01, 0x0D, 0x10, 0x00, 0x08, // PCERR Object Header
0x00, 0x00, 0x01, 0x03, 0x01, 0x10, 0x00, 0x20, // OPEN object header
......@@ -133,7 +129,7 @@ public class PcepErrorMsgTest {
0x00, 0x10, 0x00, 0x04, // STATEFUL-PCE-CAPABILITY
0x00, 0x00, 0x00, 0x05, 0x00, 0x0E, 0x00, 0x04, // GMPLS-CAPABILITY-TLV
0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, // PCECC-CAPABILITY-TLV
0x00, 0x00, 0x00, 0x03 };
0x00, 0x00, 0x00, 0x03};
ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
buffer.writeBytes(errorMsg);
......@@ -143,36 +139,33 @@ public class PcepErrorMsgTest {
message = reader.readFrom(buffer);
byte[] testErrorMsg = {0 };
byte[] testErrorMsg = {0};
ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
Assert.assertTrue("PcepMessage is not instance of PcepErrorMsg", message instanceof PcepErrorMsg);
assertThat(message, sameInstance((PcepErrorMsg) message));
message.writeTo(buf);
int iReadLen = buf.writerIndex() - 0;
int iReadLen = buf.writerIndex();
testErrorMsg = new byte[iReadLen];
buf.readBytes(testErrorMsg, 0, iReadLen);
Assert.assertArrayEquals("PcepErrorMsg messages are not equal", errorMsg, testErrorMsg);
assertThat(testErrorMsg, is(errorMsg));
}
/**
* This test case checks for
* PCEP-ERROR Object, PCEP-ERROR Object, OPEN Object (STATEFUL-PCE-CAPABILITY, GMPLS-CAPABILITY-TLV)
* in PcepErrorMsg message.
*
* @throws PcepParseException while parsing PCEP message
*/
@Test
public void errorMessageTest4() throws PcepParseException {
byte[] errorMsg = new byte[] {0x20, 0x06, 0x00, 0x2c, // common header
byte[] errorMsg = new byte[]{0x20, 0x06, 0x00, 0x2c, // common header
0x0D, 0x10, 0x00, 0x08, // PCERR Object Header
0x00, 0x00, 0x01, 0x01, 0x0D, 0x10, 0x00, 0x08, // PCERR Object Header
0x00, 0x00, 0x01, 0x03, 0x01, 0x10, 0x00, 0x18, // OPEN object header
0x20, 0x05, 0x1E, 0x01, // OPEN object
0x00, 0x10, 0x00, 0x04, // STATEFUL-PCE-CAPABILITY
0x00, 0x00, 0x00, 0x05, 0x00, 0x0E, 0x00, 0x04, // GMPLS-CAPABILITY-TLV
0x00, 0x00, 0x00, 0x00 };
0x00, 0x00, 0x00, 0x00};
ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
buffer.writeBytes(errorMsg);
......@@ -182,35 +175,32 @@ public class PcepErrorMsgTest {
message = reader.readFrom(buffer);
byte[] testErrorMsg = {0 };
byte[] testErrorMsg = {0};
ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
Assert.assertTrue("PcepMessage is not instance of PcepErrorMsg", message instanceof PcepErrorMsg);
assertThat(message, sameInstance((PcepErrorMsg) message));
message.writeTo(buf);
int iReadLen = buf.writerIndex() - 0;
int iReadLen = buf.writerIndex();
testErrorMsg = new byte[iReadLen];
buf.readBytes(testErrorMsg, 0, iReadLen);
Assert.assertArrayEquals("PcepErrorMsg messages are not equal", errorMsg, testErrorMsg);
assertThat(testErrorMsg, is(errorMsg));
}
/**
* This test case checks for
* PCEP-ERROR Object, PCEP-ERROR Object, OPEN Object (STATEFUL-PCE-CAPABILITY)
* in PcepErrorMsg message.
*
* @throws PcepParseException while parsing PCEP message
*/
@Test
public void errorMessageTest5() throws PcepParseException {
byte[] errorMsg = new byte[] {0x20, 0x06, 0x00, 0x24, // common header
byte[] errorMsg = new byte[]{0x20, 0x06, 0x00, 0x24, // common header
0x0D, 0x10, 0x00, 0x08, // PCERR Object Header
0x00, 0x00, 0x01, 0x01, 0x0D, 0x10, 0x00, 0x08, // PCERR Object Header
0x00, 0x00, 0x01, 0x03, 0x01, 0x10, 0x00, 0x10, // OPEN object header
0x20, 0x05, 0x1E, 0x01, // OPEN object
0x00, 0x10, 0x00, 0x04, // STATEFUL-PCE-CAPABILITY
0x00, 0x00, 0x00, 0x05 };
0x00, 0x00, 0x00, 0x05};
ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
buffer.writeBytes(errorMsg);
......@@ -220,29 +210,26 @@ public class PcepErrorMsgTest {
message = reader.readFrom(buffer);
byte[] testErrorMsg = {0 };
byte[] testErrorMsg = {0};
ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
Assert.assertTrue("PcepMessage is not instance of PcepErrorMsg", message instanceof PcepErrorMsg);
assertThat(message, sameInstance((PcepErrorMsg) message));
message.writeTo(buf);
int iReadLen = buf.writerIndex() - 0;
int iReadLen = buf.writerIndex();
testErrorMsg = new byte[iReadLen];
buf.readBytes(testErrorMsg, 0, iReadLen);
Assert.assertArrayEquals("PcepErrorMsg messages are not equal", errorMsg, testErrorMsg);
assertThat(testErrorMsg, is(errorMsg));
}
/**
* This test case checks for
* PCEP-ERROR Object, PCEP-ERROR Object, OPEN Object
* in PcepErrorMsg message.
*
* @throws PcepParseException while parsing PCEP message
*/
@Test
public void errorMessageTest6() throws PcepParseException {
byte[] errorMsg = new byte[] {0x20, 0x06, 0x00, 0x1C, // common header
byte[] errorMsg = new byte[]{0x20, 0x06, 0x00, 0x1C, // common header
0x0D, 0x10, 0x00, 0x08, // PCERR Object Header
0x00, 0x00, 0x01, 0x01, 0x0D, 0x10, 0x00, 0x08, // PCERR Object Header
0x00, 0x00, 0x01, 0x03, 0x01, 0x10, 0x00, 0x08, // OPEN object header
......@@ -257,29 +244,26 @@ public class PcepErrorMsgTest {
message = reader.readFrom(buffer);
byte[] testErrorMsg = {0 };
byte[] testErrorMsg = {0};
ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
Assert.assertTrue("PcepMessage is not instance of PcepErrorMsg", message instanceof PcepErrorMsg);
assertThat(message, sameInstance((PcepErrorMsg) message));
message.writeTo(buf);
int iReadLen = buf.writerIndex() - 0;
int iReadLen = buf.writerIndex();
testErrorMsg = new byte[iReadLen];
buf.readBytes(testErrorMsg, 0, iReadLen);
Assert.assertArrayEquals("PcepErrorMsg messages are not equal", errorMsg, testErrorMsg);
assertThat(testErrorMsg, is(errorMsg));
}
/**
* This test case checks for
* PCEP-ERROR Object, OPEN Object
* in PcepErrorMsg message.
*
* @throws PcepParseException while parsing PCEP message
*/
@Test
public void errorMessageTest7() throws PcepParseException {
byte[] errorMsg = new byte[] {0x20, 0x06, 0x00, 0x14, // common header
byte[] errorMsg = new byte[]{0x20, 0x06, 0x00, 0x14, // common header
0x0D, 0x10, 0x00, 0x08, // PCERR Object Header
0x00, 0x00, 0x01, 0x01, 0x01, 0x10, 0x00, 0x08, // OPEN object header
0x20, 0x05, 0x1E, 0x01 // OPEN object
......@@ -293,33 +277,30 @@ public class PcepErrorMsgTest {
message = reader.readFrom(buffer);
byte[] testErrorMsg = {0 };
byte[] testErrorMsg = {0};
ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
Assert.assertTrue("PcepMessage is not instance of PcepErrorMsg", message instanceof PcepErrorMsg);
assertThat(message, sameInstance((PcepErrorMsg) message));
message.writeTo(buf);
int iReadLen = buf.writerIndex() - 0;
int iReadLen = buf.writerIndex();
testErrorMsg = new byte[iReadLen];
buf.readBytes(testErrorMsg, 0, iReadLen);
Assert.assertArrayEquals("PcepErrorMsg messages are not equal", errorMsg, testErrorMsg);
assertThat(testErrorMsg, is(errorMsg));
}
/**
* This test case checks for
* PCEP-ERROR Object, RP Object, PCEP-ERROR Object
* in PcepErrorMsg message.
*
* @throws PcepParseException while parsing PCEP message
*/
@Test
public void errorMessageTest8() throws PcepParseException {
byte[] errorMsg = new byte[] {0x20, 0x06, 0x00, 0x20, // common header
byte[] errorMsg = new byte[]{0x20, 0x06, 0x00, 0x20, // common header
0x0D, 0x10, 0x00, 0x08, // PCERR Object Header
0x00, 0x00, 0x01, 0x01, 0x02, 0x10, 0x00, 0x0C, // RP Object Header
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x0D, 0x10, 0x00, 0x08, // PCERR Object Header
0x00, 0x00, 0x01, 0x03 };
0x00, 0x00, 0x01, 0x03};
ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
buffer.writeBytes(errorMsg);
......@@ -329,32 +310,29 @@ public class PcepErrorMsgTest {
message = reader.readFrom(buffer);
byte[] testErrorMsg = {0 };
byte[] testErrorMsg = {0};
ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
Assert.assertTrue("PcepMessage is not instance of PcepErrorMsg", message instanceof PcepErrorMsg);
assertThat(message, sameInstance((PcepErrorMsg) message));
message.writeTo(buf);
int iReadLen = buf.writerIndex() - 0;
int iReadLen = buf.writerIndex();
testErrorMsg = new byte[iReadLen];
buf.readBytes(testErrorMsg, 0, iReadLen);
Assert.assertArrayEquals("PcepErrorMsg messages are not equal", errorMsg, testErrorMsg);
assertThat(testErrorMsg, is(errorMsg));
}
/**
* This test case checks for
* PCEP-ERROR Object, PCEP-ERROR Object
* in PcepErrorMsg message.
*
* @throws PcepParseException while parsing PCEP message
*/
@Test
public void errorMessageTest9() throws PcepParseException {
byte[] errorMsg = new byte[] {0x20, 0x06, 0x00, 0x14, // common header
byte[] errorMsg = new byte[]{0x20, 0x06, 0x00, 0x14, // common header
0x0D, 0x10, 0x00, 0x08, // PCEP-ERROR Object Header
0x00, 0x00, 0x01, 0x01, 0x0D, 0x10, 0x00, 0x08, // PCEP-ERROR Object Header
0x00, 0x00, 0x01, 0x01 };
0x00, 0x00, 0x01, 0x01};
ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
buffer.writeBytes(errorMsg);
......@@ -364,32 +342,29 @@ public class PcepErrorMsgTest {
message = reader.readFrom(buffer);
byte[] testErrorMsg = {0 };
byte[] testErrorMsg = {0};
ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
Assert.assertTrue("PcepMessage is not instance of PcepErrorMsg", message instanceof PcepErrorMsg);
assertThat(message, sameInstance((PcepErrorMsg) message));
message.writeTo(buf);
int iReadLen = buf.writerIndex() - 0;
int iReadLen = buf.writerIndex();
testErrorMsg = new byte[iReadLen];
buf.readBytes(testErrorMsg, 0, iReadLen);
Assert.assertArrayEquals("PcepErrorMsg messages are not equal", errorMsg, testErrorMsg);
assertThat(testErrorMsg, is(errorMsg));
}
/**
* This test case checks for
* PCEP-ERROR Object, PCEP-ERROR Object
* in PcepErrorMsg message.
*
* @throws PcepParseException while parsing PCEP message
*/
@Test
public void errorMessageTest10() throws PcepParseException {
byte[] errorMsg = new byte[] {0x20, 0x06, 0x00, 0x14, // common header
byte[] errorMsg = new byte[]{0x20, 0x06, 0x00, 0x14, // common header
0x0D, 0x10, 0x00, 0x08, // PCEP-ERROR Object Header
0x00, 0x00, 0x01, 0x01, 0x0D, 0x10, 0x00, 0x08, // PCEP-ERROR Object Header
0x00, 0x00, 0x01, 0x01 };
0x00, 0x00, 0x01, 0x01};
ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
buffer.writeBytes(errorMsg);
......@@ -399,33 +374,30 @@ public class PcepErrorMsgTest {
message = reader.readFrom(buffer);
byte[] testErrorMsg = {0 };
byte[] testErrorMsg = {0};
ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
Assert.assertTrue("PcepMessage is not instance of PcepErrorMsg", message instanceof PcepErrorMsg);
assertThat(message, sameInstance((PcepErrorMsg) message));
message.writeTo(buf);
int iReadLen = buf.writerIndex() - 0;
int iReadLen = buf.writerIndex();
testErrorMsg = new byte[iReadLen];
buf.readBytes(testErrorMsg, 0, iReadLen);
Assert.assertArrayEquals("PcepErrorMsg messages are not equal", errorMsg, testErrorMsg);
assertThat(testErrorMsg, is(errorMsg));
}
/**
* This test case checks for
* TE Object, PCEP-ERROR Object
* in PcepErrorMsg message.
*
* @throws PcepParseException while parsing PCEP message
*/
@Test
public void errorMessageTest11() throws PcepParseException {
byte[] errorMsg = new byte[] {0x20, 0x06, 0x00, 0x18, // common header
byte[] errorMsg = new byte[]{0x20, 0x06, 0x00, 0x18, // common header
0x65, 0x13, 0x00, 0x0C, // TE Object Header
0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x10, // TE-ID
0x0D, 0x10, 0x00, 0x08, // PCEP-ERROR Object Header
0x00, 0x00, 0x01, 0x01 };
0x00, 0x00, 0x01, 0x01};
ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
buffer.writeBytes(errorMsg);
......@@ -435,33 +407,30 @@ public class PcepErrorMsgTest {
message = reader.readFrom(buffer);
byte[] testErrorMsg = {0 };
byte[] testErrorMsg = {0};
ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
Assert.assertTrue("PcepMessage is not instance of PcepErrorMsg", message instanceof PcepErrorMsg);
assertThat(message, sameInstance((PcepErrorMsg) message));
message.writeTo(buf);
int iReadLen = buf.writerIndex() - 0;
int iReadLen = buf.writerIndex();
testErrorMsg = new byte[iReadLen];
buf.readBytes(testErrorMsg, 0, iReadLen);
Assert.assertArrayEquals("PcepErrorMsg messages are not equal", errorMsg, testErrorMsg);
assertThat(testErrorMsg, is(errorMsg));
}
/**
* This test case checks for
* RP Object, PCEP-ERROR Object
* in PcepErrorMsg message.
*
* @throws PcepParseException while parsing PCEP message
*/
@Test
public void errorMessageTest12() throws PcepParseException {
//RP Object, PCEP-ERROR Object
byte[] errorMsg = new byte[] {0x20, 0x06, 0x00, 0x18, // common header
byte[] errorMsg = new byte[]{0x20, 0x06, 0x00, 0x18, // common header
0x02, 0x10, 0x00, 0x0C, // RP Object Header
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x0D, 0x10, 0x00, 0x08, // PCEP-ERROR Object Header
0x00, 0x00, 0x01, 0x01 };
0x00, 0x00, 0x01, 0x01};
ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
buffer.writeBytes(errorMsg);
......@@ -471,33 +440,30 @@ public class PcepErrorMsgTest {
message = reader.readFrom(buffer);
byte[] testErrorMsg = {0 };
byte[] testErrorMsg = {0};
ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
Assert.assertTrue("PcepMessage is not instance of PcepErrorMsg", message instanceof PcepErrorMsg);
assertThat(message, sameInstance((PcepErrorMsg) message));
message.writeTo(buf);
int iReadLen = buf.writerIndex() - 0;
int iReadLen = buf.writerIndex();
testErrorMsg = new byte[iReadLen];
buf.readBytes(testErrorMsg, 0, iReadLen);
Assert.assertArrayEquals("PcepErrorMsg messages are not equal", errorMsg, testErrorMsg);
assertThat(testErrorMsg, is(errorMsg));
}
/**
* This test case checks for
* RP Object, RP Object, PCEP-ERROR Object
* in PcepErrorMsg message.
*
* @throws PcepParseException while parsing PCEP message
*/
@Test
public void errorMessageTest13() throws PcepParseException {
byte[] errorMsg = new byte[] {0x20, 0x06, 0x00, 0x24, // common header
byte[] errorMsg = new byte[]{0x20, 0x06, 0x00, 0x24, // common header
0x02, 0x10, 0x00, 0x0C, // RP Object Header
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x02, 0x10, 0x00, 0x0C, // RP Object Header
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x0D, 0x10, 0x00, 0x08, // PCEP-ERROR Object Header
0x00, 0x00, 0x01, 0x01 };
0x00, 0x00, 0x01, 0x01};
ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
buffer.writeBytes(errorMsg);
......@@ -507,35 +473,32 @@ public class PcepErrorMsgTest {
message = reader.readFrom(buffer);
byte[] testErrorMsg = {0 };
byte[] testErrorMsg = {0};
ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
Assert.assertTrue("PcepMessage is not instance of PcepErrorMsg", message instanceof PcepErrorMsg);
assertThat(message, sameInstance((PcepErrorMsg) message));
message.writeTo(buf);
int iReadLen = buf.writerIndex() - 0;
int iReadLen = buf.writerIndex();
testErrorMsg = new byte[iReadLen];
buf.readBytes(testErrorMsg, 0, iReadLen);
Assert.assertArrayEquals("PcepErrorMsg messages are not equal", errorMsg, testErrorMsg);
assertThat(testErrorMsg, is(errorMsg));
}
/**
* This test case checks for
* TE Object, TE Object, PCEP-ERROR Object
* in PcepErrorMsg message.
*
* @throws PcepParseException while parsing PCEP message
*/
@Test
public void errorMessageTest14() throws PcepParseException {
byte[] errorMsg = new byte[] {0x20, 0x06, 0x00, 0x24, // common header
byte[] errorMsg = new byte[]{0x20, 0x06, 0x00, 0x24, // common header
0x65, 0x10, 0x00, 0x0C, // TE Object Header
0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x10, // TE-ID
0x65, 0x10, 0x00, 0x0C, // TE Object Header
0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x11, // TE-ID
0x0D, 0x10, 0x00, 0x08, // PCEP-ERROR Object Header
0x00, 0x00, 0x01, 0x01 };
0x00, 0x00, 0x01, 0x01};
ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
buffer.writeBytes(errorMsg);
......@@ -545,34 +508,31 @@ public class PcepErrorMsgTest {
message = reader.readFrom(buffer);
byte[] testErrorMsg = {0 };
byte[] testErrorMsg = {0};
ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
Assert.assertTrue("PcepMessage is not instance of PcepErrorMsg", message instanceof PcepErrorMsg);
assertThat(message, sameInstance((PcepErrorMsg) message));
message.writeTo(buf);
int iReadLen = buf.writerIndex() - 0;
int iReadLen = buf.writerIndex();
testErrorMsg = new byte[iReadLen];
buf.readBytes(testErrorMsg, 0, iReadLen);
Assert.assertArrayEquals("PcepErrorMsg messages are not equal", errorMsg, testErrorMsg);
assertThat(testErrorMsg, is(errorMsg));
}
/**
* This test case checks for
* PCEP-ERROR Object, TE Object, PCEP-ERROR Object
* in PcepErrorMsg message.
*
* @throws PcepParseException while parsing PCEP message
*/
@Test
public void errorMessageTest15() throws PcepParseException {
byte[] errorMsg = new byte[] {0x20, 0x06, 0x00, 0x20, // common header
byte[] errorMsg = new byte[]{0x20, 0x06, 0x00, 0x20, // common header
0x0D, 0x10, 0x00, 0x08, // PCERR Object Header
0x00, 0x00, 0x01, 0x01, 0x65, 0x10, 0x00, 0x0C, // TE Object Header
0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x10, // TE-ID
0x0D, 0x10, 0x00, 0x08, // PCEP-ERROR Object Header
0x00, 0x00, 0x01, 0x03 };
0x00, 0x00, 0x01, 0x03};
ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
buffer.writeBytes(errorMsg);
......@@ -582,34 +542,31 @@ public class PcepErrorMsgTest {
message = reader.readFrom(buffer);
byte[] testErrorMsg = {0 };
byte[] testErrorMsg = {0};
ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
Assert.assertTrue("PcepMessage is not instance of PcepErrorMsg", message instanceof PcepErrorMsg);
assertThat(message, sameInstance((PcepErrorMsg) message));
message.writeTo(buf);
int iReadLen = buf.writerIndex() - 0;
int iReadLen = buf.writerIndex();
testErrorMsg = new byte[iReadLen];
buf.readBytes(testErrorMsg, 0, iReadLen);
Assert.assertArrayEquals("PcepErrorMsg messages are not equal", errorMsg, testErrorMsg);
assertThat(testErrorMsg, is(errorMsg));
}
/**
* This test case checks for
* PCEP-ERROR Object, RP Object, RP Object, PCEP-ERROR Object
* in PcepErrorMsg message.
*
* @throws PcepParseException while parsing PCEP message
*/
@Test
public void errorMessageTest16() throws PcepParseException {
byte[] errorMsg = new byte[] {0x20, 0x06, 0x00, 0x2C, // common header
byte[] errorMsg = new byte[]{0x20, 0x06, 0x00, 0x2C, // common header
0x0D, 0x10, 0x00, 0x08, // PCEP-ERROR Object Header
0x00, 0x00, 0x01, 0x01, 0x02, 0x10, 0x00, 0x0C, // RP Object Header
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x02, 0x10, 0x00, 0x0C, // RP Object Header
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x0D, 0x10, 0x00, 0x08, // PCERR Object Header
0x00, 0x00, 0x01, 0x03 };
0x00, 0x00, 0x01, 0x03};
ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
buffer.writeBytes(errorMsg);
......@@ -619,36 +576,33 @@ public class PcepErrorMsgTest {
message = reader.readFrom(buffer);
byte[] testErrorMsg = {0 };
byte[] testErrorMsg = {0};
ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
Assert.assertTrue("PcepMessage is not instance of PcepErrorMsg", message instanceof PcepErrorMsg);
assertThat(message, sameInstance((PcepErrorMsg) message));
message.writeTo(buf);
int iReadLen = buf.writerIndex() - 0;
int iReadLen = buf.writerIndex();
testErrorMsg = new byte[iReadLen];
buf.readBytes(testErrorMsg, 0, iReadLen);
Assert.assertArrayEquals("PcepErrorMsg messages are not equal", errorMsg, testErrorMsg);
assertThat(testErrorMsg, is(errorMsg));
}
/**
* This test case checks for
* PCEP-ERROR Object, TE Object, TE Object, PCEP-ERROR Object
* in PcepErrorMsg message.
*
* @throws PcepParseException while parsing PCEP message
*/
@Test
public void errorMessageTest17() throws PcepParseException {
byte[] errorMsg = new byte[] {0x20, 0x06, 0x00, 0x2C, // common header
byte[] errorMsg = new byte[]{0x20, 0x06, 0x00, 0x2C, // common header
0x0D, 0x10, 0x00, 0x08, // PCEP-ERROR Object Header
0x00, 0x00, 0x01, 0x01, 0x65, 0x10, 0x00, 0x0C, // TE Object Header
0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x10, // TE-ID
0x65, 0x10, 0x00, 0x0C, // TE Object Header
0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x11, // TE-ID
0x0D, 0x10, 0x00, 0x08, // PCEP-ERROR Object Header
0x00, 0x00, 0x01, 0x03 };
0x00, 0x00, 0x01, 0x03};
ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
buffer.writeBytes(errorMsg);
......@@ -658,36 +612,33 @@ public class PcepErrorMsgTest {
message = reader.readFrom(buffer);
byte[] testErrorMsg = {0 };
byte[] testErrorMsg = {0};
ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
Assert.assertTrue("PcepMessage is not instance of PcepErrorMsg", message instanceof PcepErrorMsg);
assertThat(message, sameInstance((PcepErrorMsg) message));
message.writeTo(buf);
int iReadLen = buf.writerIndex() - 0;
int iReadLen = buf.writerIndex();
testErrorMsg = new byte[iReadLen];
buf.readBytes(testErrorMsg, 0, iReadLen);
Assert.assertArrayEquals("PcepErrorMsg messages are not equal", errorMsg, testErrorMsg);
assertThat(testErrorMsg, is(errorMsg));
}
/**
* This test case checks for
* PCEP-ERROR Object, PCEP-ERROR Object, RP Object, RP Object, PCEP-ERROR Object, PCEP-ERROR Object
* in PcepErrorMsg message.
*
* @throws PcepParseException while parsing PCEP message
*/
@Test
public void errorMessageTest18() throws PcepParseException {
byte[] errorMsg = new byte[] {0x20, 0x06, 0x00, 0x3C, // common header
byte[] errorMsg = new byte[]{0x20, 0x06, 0x00, 0x3C, // common header
0x0D, 0x10, 0x00, 0x08, // PCEP-ERROR Object Header
0x00, 0x00, 0x01, 0x01, 0x0D, 0x10, 0x00, 0x08, // PCEP-ERROR Object Header
0x00, 0x00, 0x01, 0x03, 0x02, 0x10, 0x00, 0x0C, // RP Object Header
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x02, 0x10, 0x00, 0x0C, // RP Object Header
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x0D, 0x10, 0x00, 0x08, // PCEP-ERROR Object Header
0x00, 0x00, 0x01, 0x04, 0x0D, 0x10, 0x00, 0x08, // PCEP-ERROR Object Header
0x00, 0x00, 0x01, 0x06 };
0x00, 0x00, 0x01, 0x06};
ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
buffer.writeBytes(errorMsg);
......@@ -697,29 +648,26 @@ public class PcepErrorMsgTest {
message = reader.readFrom(buffer);
byte[] testErrorMsg = {0 };
byte[] testErrorMsg = {0};
ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
Assert.assertTrue("PcepMessage is not instance of PcepErrorMsg", message instanceof PcepErrorMsg);
assertThat(message, sameInstance((PcepErrorMsg) message));
message.writeTo(buf);
int iReadLen = buf.writerIndex() - 0;
int iReadLen = buf.writerIndex();
testErrorMsg = new byte[iReadLen];
buf.readBytes(testErrorMsg, 0, iReadLen);
Assert.assertArrayEquals("PcepErrorMsg messages are not equal", errorMsg, testErrorMsg);
assertThat(testErrorMsg, is(errorMsg));
}
/**
* This test case checks for
* PCEP-ERROR Object, PCEP-ERROR Object, TE Object, TE Object, PCEP-ERROR Object, PCEP-ERROR Object
* in PcepErrorMsg message.
*
* @throws PcepParseException while parsing PCEP message
*/
@Test
public void errorMessageTest19() throws PcepParseException {
byte[] errorMsg = new byte[] {0x20, 0x06, 0x00, 0x3C, // common header
byte[] errorMsg = new byte[]{0x20, 0x06, 0x00, 0x3C, // common header
0x0D, 0x10, 0x00, 0x08, // PCERR Object Header
0x00, 0x00, 0x01, 0x01, 0x0D, 0x10, 0x00, 0x08, // PCERR Object Header
0x00, 0x00, 0x01, 0x03, 0x65, 0x10, 0x00, 0x0C, // TE Object Header
......@@ -728,7 +676,7 @@ public class PcepErrorMsgTest {
0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x11, // TE-ID
0x0D, 0x10, 0x00, 0x08, // PCERR Object Header
0x00, 0x00, 0x01, 0x04, 0x0D, 0x10, 0x00, 0x08, // PCERR Object Header
0x00, 0x00, 0x01, 0x06 };
0x00, 0x00, 0x01, 0x06};
ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
buffer.writeBytes(errorMsg);
......@@ -738,16 +686,15 @@ public class PcepErrorMsgTest {
message = reader.readFrom(buffer);
byte[] testErrorMsg = {0 };
byte[] testErrorMsg = {0};
ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
Assert.assertTrue("PcepMessage is not instance of PcepErrorMsg", message instanceof PcepErrorMsg);
assertThat(message, sameInstance((PcepErrorMsg) message));
message.writeTo(buf);
int iReadLen = buf.writerIndex() - 0;
int iReadLen = buf.writerIndex();
testErrorMsg = new byte[iReadLen];
buf.readBytes(testErrorMsg, 0, iReadLen);
Assert.assertArrayEquals("PcepErrorMsg messages are not equal", errorMsg, testErrorMsg);
assertThat(testErrorMsg, is(errorMsg));
}
/**
......@@ -755,13 +702,11 @@ public class PcepErrorMsgTest {
* PCEP-ERROR Object, RP Object, RP Object, PCEP-ERROR Object, PCEP-ERROR Object,
* TE Object, PCEP-ERROR Object
* in PcepErrorMsg message.
*
* @throws PcepParseException while parsing PCEP message
*/
@Test
public void errorMessageTest20() throws PcepParseException {
byte[] errorMsg = new byte[] {0x20, 0x06, 0x00, 0x48, // common header
byte[] errorMsg = new byte[]{0x20, 0x06, 0x00, 0x48, // common header
0x0D, 0x10, 0x00, 0x08, // PCEP-ERROR Object Header
0x00, 0x00, 0x01, 0x01, 0x02, 0x10, 0x00, 0x0C, // RP Object Header
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x02, 0x10, 0x00, 0x0C, // RP Object Header
......@@ -770,7 +715,7 @@ public class PcepErrorMsgTest {
0x00, 0x00, 0x01, 0x06, 0x65, 0x10, 0x00, 0x0C, // TE Object Header
0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x10, // TE-ID
0x0D, 0x10, 0x00, 0x08, // PCERR Object Header
0x00, 0x00, 0x01, 0x06 };
0x00, 0x00, 0x01, 0x06};
ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
buffer.writeBytes(errorMsg);
......@@ -780,16 +725,15 @@ public class PcepErrorMsgTest {
message = reader.readFrom(buffer);
byte[] testErrorMsg = {0 };
byte[] testErrorMsg = {0};
ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
Assert.assertTrue("PcepMessage is not instance of PcepErrorMsg", message instanceof PcepErrorMsg);
assertThat(message, sameInstance((PcepErrorMsg) message));
message.writeTo(buf);
int iReadLen = buf.writerIndex() - 0;
int iReadLen = buf.writerIndex();
testErrorMsg = new byte[iReadLen];
buf.readBytes(testErrorMsg, 0, iReadLen);
Assert.assertArrayEquals("PcepErrorMsg messages are not equal", errorMsg, testErrorMsg);
assertThat(testErrorMsg, is(errorMsg));
}
}
......