OpenApi add POST request to device root
[netconf.git] / netconf / netconf-netty-util / src / test / java / org / opendaylight / netconf / nettyutil / handler / ChunkedFramingMechanismEncoderTest.java
index bb95ff1b0223e8390d22769f7b8eb2649270735b..e641ed9981184caaa237465db997e5627d09529f 100644 (file)
@@ -8,46 +8,42 @@
 
 package org.opendaylight.netconf.nettyutil.handler;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 import io.netty.buffer.ByteBuf;
 import io.netty.buffer.Unpooled;
 import io.netty.channel.ChannelHandlerContext;
 import java.nio.ByteBuffer;
 import java.nio.charset.StandardCharsets;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
 import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.jupiter.MockitoExtension;
 
-public class ChunkedFramingMechanismEncoderTest {
+@ExtendWith(MockitoExtension.class)
+class ChunkedFramingMechanismEncoderTest {
 
-    private int chunkSize;
+    private static final int CHUNK_SIZE = 256;
     @Mock
     private ChannelHandlerContext ctx;
 
-    @Before
-    public void setUp() throws Exception {
-        MockitoAnnotations.initMocks(this);
-        chunkSize = 256;
-    }
-
-    @Test(expected = IllegalArgumentException.class)
-    public void testIllegalSize() throws Exception {
-        new ChunkedFramingMechanismEncoder(10);
+    @Test
+    void testIllegalSize() {
+        assertThrows(IllegalArgumentException.class, () -> new ChunkedFramingMechanismEncoder(10));
     }
 
-    @Test(expected = IllegalArgumentException.class)
-    public void testIllegalSizeMax() throws Exception {
-        new ChunkedFramingMechanismEncoder(Integer.MAX_VALUE);
+    @Test
+    void testIllegalSizeMax() {
+        assertThrows(IllegalArgumentException.class, () -> new ChunkedFramingMechanismEncoder(Integer.MAX_VALUE));
     }
 
     @Test
-    public void testEncode() throws Exception {
-        final ChunkedFramingMechanismEncoder encoder = new ChunkedFramingMechanismEncoder(chunkSize);
+    void testEncode() {
+        final ChunkedFramingMechanismEncoder encoder = new ChunkedFramingMechanismEncoder(CHUNK_SIZE);
         final int lastChunkSize = 20;
-        final ByteBuf src = Unpooled.wrappedBuffer(getByteArray(chunkSize * 4 + lastChunkSize));
+        final ByteBuf src = Unpooled.wrappedBuffer(getByteArray(CHUNK_SIZE * 4 + lastChunkSize));
         final ByteBuf destination = Unpooled.buffer();
         encoder.encode(ctx, src, destination);