Priyanka bhaskar
Committed by Ray Milkey

UT for Pcep Report message (updated with AssertThat).

Change-Id: Ieebfbc2c2e64165a6cf316e98d4a013bf1060547
...@@ -15,9 +15,11 @@ ...@@ -15,9 +15,11 @@
15 */ 15 */
16 package org.onosproject.pcepio; 16 package org.onosproject.pcepio;
17 17
18 +import static org.hamcrest.MatcherAssert.assertThat;
19 +import static org.hamcrest.Matchers.instanceOf;
20 +import static org.hamcrest.core.Is.is;
18 import org.jboss.netty.buffer.ChannelBuffer; 21 import org.jboss.netty.buffer.ChannelBuffer;
19 import org.jboss.netty.buffer.ChannelBuffers; 22 import org.jboss.netty.buffer.ChannelBuffers;
20 -import org.junit.Assert;
21 import org.junit.Test; 23 import org.junit.Test;
22 import org.onosproject.pcepio.exceptions.PcepParseException; 24 import org.onosproject.pcepio.exceptions.PcepParseException;
23 import org.onosproject.pcepio.protocol.PcepFactories; 25 import org.onosproject.pcepio.protocol.PcepFactories;
...@@ -31,8 +33,6 @@ public class PcepReportMsgTest2 { ...@@ -31,8 +33,6 @@ public class PcepReportMsgTest2 {
31 * This test case checks forSRP Object,LSP Object(symbolic path tlv),ERO Object 33 * This test case checks forSRP Object,LSP Object(symbolic path tlv),ERO Object
32 * SRP Object,LSP Object(symbolic path tlv,ERO Object,LSPA Object,BandWidth Object,Metric-list,RRO Object 34 * SRP Object,LSP Object(symbolic path tlv,ERO Object,LSPA Object,BandWidth Object,Metric-list,RRO Object
33 * in PcRpt message. 35 * in PcRpt message.
34 - *
35 - * @throws PcepParseException while parsing PCEP message
36 */ 36 */
37 @Test 37 @Test
38 public void reportMessageTest39() throws PcepParseException { 38 public void reportMessageTest39() throws PcepParseException {
...@@ -65,23 +65,21 @@ public class PcepReportMsgTest2 { ...@@ -65,23 +65,21 @@ public class PcepReportMsgTest2 {
65 PcepMessage message = null; 65 PcepMessage message = null;
66 66
67 message = reader.readFrom(buffer); 67 message = reader.readFrom(buffer);
68 - Assert.assertTrue("PcepMessage is not instance of PcRpt", message instanceof PcepReportMsg); 68 + assertThat(message, instanceOf(PcepReportMsg.class));
69 ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); 69 ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
70 message.writeTo(buf); 70 message.writeTo(buf);
71 71
72 - int readLen = buf.writerIndex() - 0; 72 + int readLen = buf.writerIndex();
73 testReportMsg = new byte[readLen]; 73 testReportMsg = new byte[readLen];
74 buf.readBytes(testReportMsg, 0, readLen); 74 buf.readBytes(testReportMsg, 0, readLen);
75 75
76 - Assert.assertArrayEquals("PcRpt messages are not equal", reportMsg, testReportMsg); 76 + assertThat(testReportMsg, is(reportMsg));
77 } 77 }
78 78
79 /** 79 /**
80 * This test case checks for SRP Object,LSP Object(symbolic path tlv),ERO Object 80 * This test case checks for SRP Object,LSP Object(symbolic path tlv),ERO Object
81 * SRP Object,LSP Object(symbolic path tlv),ERO Object 81 * SRP Object,LSP Object(symbolic path tlv),ERO Object
82 * in PcRpt message. 82 * in PcRpt message.
83 - *
84 - * @throws PcepParseException while parsing PCEP message
85 */ 83 */
86 @Test 84 @Test
87 public void reportMessageTest40() throws PcepParseException { 85 public void reportMessageTest40() throws PcepParseException {
...@@ -108,23 +106,21 @@ public class PcepReportMsgTest2 { ...@@ -108,23 +106,21 @@ public class PcepReportMsgTest2 {
108 PcepMessage message = null; 106 PcepMessage message = null;
109 107
110 message = reader.readFrom(buffer); 108 message = reader.readFrom(buffer);
111 - Assert.assertTrue("PcepMessage is not instance of PcRpt", message instanceof PcepReportMsg); 109 + assertThat(message, instanceOf(PcepReportMsg.class));
112 ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); 110 ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
113 message.writeTo(buf); 111 message.writeTo(buf);
114 112
115 - int readLen = buf.writerIndex() - 0; 113 + int readLen = buf.writerIndex();
116 testReportMsg = new byte[readLen]; 114 testReportMsg = new byte[readLen];
117 buf.readBytes(testReportMsg, 0, readLen); 115 buf.readBytes(testReportMsg, 0, readLen);
118 116
119 - Assert.assertArrayEquals("PcRpt messages are not equal", reportMsg, testReportMsg); 117 + assertThat(testReportMsg, is(reportMsg));
120 } 118 }
121 119
122 /** 120 /**
123 * This test case checks for SRP Object,LSP Object(symbolic path tlv),ERO Object,LSPA Object 121 * This test case checks for SRP Object,LSP Object(symbolic path tlv),ERO Object,LSPA Object
124 * SRP Object,LSP Object(symbolic path tlv),ERO Object,LSPA Object 122 * SRP Object,LSP Object(symbolic path tlv),ERO Object,LSPA Object
125 * in PcRpt message. 123 * in PcRpt message.
126 - *
127 - * @throws PcepParseException while parsing PCEP message
128 */ 124 */
129 @Test 125 @Test
130 public void reportMessageTest41() throws PcepParseException { 126 public void reportMessageTest41() throws PcepParseException {
...@@ -155,15 +151,15 @@ public class PcepReportMsgTest2 { ...@@ -155,15 +151,15 @@ public class PcepReportMsgTest2 {
155 PcepMessage message = null; 151 PcepMessage message = null;
156 152
157 message = reader.readFrom(buffer); 153 message = reader.readFrom(buffer);
158 - Assert.assertTrue("PcepMessage is not instance of PcRpt", message instanceof PcepReportMsg); 154 + assertThat(message, instanceOf(PcepReportMsg.class));
159 ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); 155 ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
160 message.writeTo(buf); 156 message.writeTo(buf);
161 157
162 - int readLen = buf.writerIndex() - 0; 158 + int readLen = buf.writerIndex();
163 testReportMsg = new byte[readLen]; 159 testReportMsg = new byte[readLen];
164 buf.readBytes(testReportMsg, 0, readLen); 160 buf.readBytes(testReportMsg, 0, readLen);
165 161
166 - Assert.assertArrayEquals("PcRpt messages are not equal", reportMsg, testReportMsg); 162 + assertThat(testReportMsg, is(reportMsg));
167 } 163 }
168 164
169 /** 165 /**
...@@ -171,8 +167,6 @@ public class PcepReportMsgTest2 { ...@@ -171,8 +167,6 @@ public class PcepReportMsgTest2 {
171 * Metric-list SRP Object,LSP Object(symbolic path tlv),ERO Object,LSPA Object,BandWidth Object,Metric-list, 167 * Metric-list SRP Object,LSP Object(symbolic path tlv),ERO Object,LSPA Object,BandWidth Object,Metric-list,
172 * RRO Object 168 * RRO Object
173 * in PcRpt message. 169 * in PcRpt message.
174 - *
175 - * @throws PcepParseException while parsing PCEP message
176 */ 170 */
177 @Test 171 @Test
178 public void reportMessageTest42() throws PcepParseException { 172 public void reportMessageTest42() throws PcepParseException {
...@@ -214,14 +208,14 @@ public class PcepReportMsgTest2 { ...@@ -214,14 +208,14 @@ public class PcepReportMsgTest2 {
214 208
215 message = reader.readFrom(buffer); 209 message = reader.readFrom(buffer);
216 210
217 - Assert.assertTrue("PcepMessage is not instance of PcRpt", message instanceof PcepReportMsg); 211 + assertThat(message, instanceOf(PcepReportMsg.class));
218 ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); 212 ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
219 message.writeTo(buf); 213 message.writeTo(buf);
220 214
221 - int readLen = buf.writerIndex() - 0; 215 + int readLen = buf.writerIndex();
222 testReportMsg = new byte[readLen]; 216 testReportMsg = new byte[readLen];
223 buf.readBytes(testReportMsg, 0, readLen); 217 buf.readBytes(testReportMsg, 0, readLen);
224 218
225 - Assert.assertArrayEquals("PcRpt messages are not equal", reportMsg, testReportMsg); 219 + assertThat(testReportMsg, is(reportMsg));
226 } 220 }
227 } 221 }
......