Committed by
Gerrit Code Review
UT for keepalive message updated with assertThat
Change-Id: I573c93291c0be1f894e7ad469e58c5c0da343e63
Showing
1 changed file
with
9 additions
and
6 deletions
... | @@ -25,12 +25,14 @@ import org.onosproject.pcepio.protocol.PcepKeepaliveMsg; | ... | @@ -25,12 +25,14 @@ import org.onosproject.pcepio.protocol.PcepKeepaliveMsg; |
25 | import org.onosproject.pcepio.protocol.PcepMessage; | 25 | import org.onosproject.pcepio.protocol.PcepMessage; |
26 | import org.onosproject.pcepio.protocol.PcepMessageReader; | 26 | import org.onosproject.pcepio.protocol.PcepMessageReader; |
27 | 27 | ||
28 | +import static org.hamcrest.MatcherAssert.assertThat; | ||
29 | +import static org.hamcrest.Matchers.instanceOf; | ||
30 | +import static org.hamcrest.core.Is.is; | ||
31 | + | ||
28 | public class PcepKeepaliveMsgTest { | 32 | public class PcepKeepaliveMsgTest { |
29 | 33 | ||
30 | /** | 34 | /** |
31 | * Common header for keep alive message. | 35 | * Common header for keep alive message. |
32 | - * | ||
33 | - * @throws PcepParseException while parsing the PCEP message. | ||
34 | */ | 36 | */ |
35 | @Test | 37 | @Test |
36 | public void keepaliveMessageTest1() throws PcepParseException { | 38 | public void keepaliveMessageTest1() throws PcepParseException { |
... | @@ -45,16 +47,17 @@ public class PcepKeepaliveMsgTest { | ... | @@ -45,16 +47,17 @@ public class PcepKeepaliveMsgTest { |
45 | PcepMessage message = null; | 47 | PcepMessage message = null; |
46 | 48 | ||
47 | message = reader.readFrom(buffer); | 49 | message = reader.readFrom(buffer); |
48 | - Assert.assertTrue("PcepMessage is not instance of PcepKeepaliveMsg", message instanceof PcepKeepaliveMsg); | 50 | + assertThat(message, instanceOf(PcepKeepaliveMsg.class)); |
49 | - | ||
50 | ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); | 51 | ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); |
52 | + | ||
51 | message.writeTo(buf); | 53 | message.writeTo(buf); |
54 | + | ||
52 | testKeepaliveMsg = buf.array(); | 55 | testKeepaliveMsg = buf.array(); |
53 | 56 | ||
54 | - int iReadLen = buf.writerIndex() - 0; | 57 | + int iReadLen = buf.writerIndex(); |
55 | testKeepaliveMsg = new byte[iReadLen]; | 58 | testKeepaliveMsg = new byte[iReadLen]; |
56 | buf.readBytes(testKeepaliveMsg, 0, iReadLen); | 59 | buf.readBytes(testKeepaliveMsg, 0, iReadLen); |
57 | 60 | ||
58 | - Assert.assertArrayEquals("PcTERpt messages are not equal", keepaliveMsg, testKeepaliveMsg); | 61 | + Assert.assertThat(testKeepaliveMsg, is(keepaliveMsg)); |
59 | } | 62 | } |
60 | } | 63 | } | ... | ... |
-
Please register or login to post a comment