OPNFLWPLUG-1032: Neon-MRI: Bump odlparent, yangtools, mdsal
[openflowplugin.git] / openflowjava / openflow-protocol-impl / src / test / java / org / opendaylight / openflowjava / protocol / impl / core / OFDecoderTest.java
index 917f9b920f30543a5405529c30c34210d2b0a7ec..a36b72917a89b9d5225577eeb0c00a640fc83213 100644 (file)
@@ -9,16 +9,14 @@
 package org.opendaylight.openflowjava.protocol.impl.core;
 
 import static org.junit.Assert.assertEquals;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.anyShort;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyShort;
 import static org.mockito.Mockito.when;
+
 import io.netty.buffer.ByteBuf;
 import io.netty.channel.ChannelHandlerContext;
-
 import java.util.ArrayList;
 import java.util.List;
-
-import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
 import org.mockito.Mock;
@@ -28,6 +26,7 @@ import org.opendaylight.openflowjava.util.ByteBufUtils;
 import org.opendaylight.yangtools.yang.binding.DataObject;
 
 /**
+ * Unit tests for OFDecoder.
  *
  * @author jameshall
  */
@@ -43,71 +42,49 @@ public class OFDecoderTest {
     private List<Object> outList;
 
     /**
-     * Sets up test environment
-     *
+     * Sets up test environment.
      */
     @Before
     public void setUp() {
         MockitoAnnotations.initMocks(this);
-        ofDecoder = new OFDecoder() ;
-        ofDecoder.setDeserializationFactory( mockDeserializationFactory ) ;
+        ofDecoder = new OFDecoder();
+        ofDecoder.setDeserializationFactory(mockDeserializationFactory);
         writeObj = ByteBufUtils.hexStringToByteBuf("16 03 01 00");
-        inMsg = new VersionMessageWrapper( (short)8, writeObj );
+        inMsg = new VersionMessageWrapper((short) 8, writeObj);
         outList = new ArrayList<>();
     }
 
-    /**
-     *
-     */
     @Test
-    public void testDecode() {
-        when(mockDeserializationFactory.deserialize( any(ByteBuf.class), anyShort() )).thenReturn(mockDataObject);
-        try {
-            ofDecoder.decode(mockChHndlrCtx, inMsg, outList);
-        } catch (Exception e) {
-            Assert.fail();
-        }
+    public void testDecode() throws Exception {
+        when(mockDeserializationFactory.deserialize(any(ByteBuf.class), anyShort())).thenReturn(mockDataObject);
+
+        ofDecoder.decode(mockChHndlrCtx, inMsg, outList);
 
         // Verify that the message buf was released...
-        assertEquals( mockDataObject, outList.get(0) ) ;
-        assertEquals( 0, writeObj.refCnt() ) ;
+        assertEquals(mockDataObject, outList.get(0));
+        assertEquals(0, writeObj.refCnt());
     }
 
-    /**
-     *
-     */
     @Test
-    public void testDecodeDeserializeException() {
-        when(mockDeserializationFactory.deserialize( any(ByteBuf.class), anyShort() ))
-        .thenThrow(new IllegalArgumentException()) ;
+    public void testDecodeDeserializeException() throws Exception {
+        when(mockDeserializationFactory.deserialize(any(ByteBuf.class), anyShort()))
+                .thenThrow(new IllegalArgumentException());
 
-        try {
-            ofDecoder.decode(mockChHndlrCtx, inMsg, outList);
-        } catch (Exception e) {
-            Assert.fail();
-        }
+        ofDecoder.decode(mockChHndlrCtx, inMsg, outList);
 
         // Verify that the message buf was released...
-        assertEquals( 0, outList.size() ) ;
-        assertEquals( 0, writeObj.refCnt() ) ;
+        assertEquals(0, outList.size());
+        assertEquals(0, writeObj.refCnt());
     }
 
-    /**
-     *
-     */
     @Test
-    public void testDecodeDeserializeNull() {
-        when(mockDeserializationFactory.deserialize( any(ByteBuf.class), anyShort() ))
-        .thenReturn(null) ;
+    public void testDecodeDeserializeNull() throws Exception {
+        when(mockDeserializationFactory.deserialize(any(ByteBuf.class), anyShort())).thenReturn(null);
 
-        try {
-            ofDecoder.decode(mockChHndlrCtx, inMsg, outList);
-        } catch (Exception e) {
-            Assert.fail();
-        }
+        ofDecoder.decode(mockChHndlrCtx, inMsg, outList);
 
         // Verify that the message buf was released...
-        assertEquals( 0, outList.size() ) ;
-        assertEquals( 0, writeObj.refCnt() ) ;
+        assertEquals(0, outList.size());
+        assertEquals(0, writeObj.refCnt());
     }
 }