Remove use of junit-addons
[lispflowmapping.git] / mappingservice / lisp-proto / src / test / java / org / opendaylight / lispflowmapping / lisp / authentication / LispAuthenticationTest.java
index 50f01ebfec380188496a26d61c41f3d6be79c27e..7daabcc7bee3f659bd1ec9532bc7befdefeae13f 100644 (file)
@@ -7,28 +7,27 @@
  */
 package org.opendaylight.lispflowmapping.lisp.authentication;
 
-import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertArrayEquals;
 import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
 
 import java.nio.ByteBuffer;
 import java.util.ArrayList;
-
-import junitx.framework.ArrayAssert;
-
 import org.junit.Test;
 import org.opendaylight.lispflowmapping.lisp.serializer.MapNotifySerializer;
-import org.opendaylight.lispflowmapping.lisp.util.LispAddressUtil;
 import org.opendaylight.lispflowmapping.lisp.serializer.MapRegisterSerializer;
+import org.opendaylight.lispflowmapping.lisp.util.LispAddressUtil;
 import org.opendaylight.lispflowmapping.tools.junit.BaseTestCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapRegister;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.locatorrecords.LocatorRecord;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapnotifymessage.MapNotifyBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecordBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.list.MappingRecordItem;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.list.MappingRecordItemBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping._record.container.MappingRecordBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping._record.list.MappingRecordItem;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping._record.list.MappingRecordItemBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.authkey.container.MappingAuthkey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.authkey.container.MappingAuthkeyBuilder;
+import org.opendaylight.yangtools.yang.common.Uint16;
 
 public class LispAuthenticationTest extends BaseTestCase {
     private static final String PASSWORD = "password";
@@ -55,7 +54,7 @@ public class LispAuthenticationTest extends BaseTestCase {
                         + "ff 00 00 05 00 01 c0 a8 88 0a");
         MapRegister mapRegister = MapRegisterSerializer.getInstance().deserialize(byteBuffer, null);
 
-        assertFalse(validate(mapRegister, byteBuffer, EID, 1, PASSWORD));
+        assertFalse(validate(mapRegister, byteBuffer, EID, Uint16.ONE, PASSWORD));
     }
 
     @Test
@@ -77,8 +76,8 @@ public class LispAuthenticationTest extends BaseTestCase {
                 + "ff 00 00 05 00 01 c0 a8 88 0a");
         MapRegister mapRegister = MapRegisterSerializer.getInstance().deserialize(byteBuffer, null);
 
-        assertTrue(validate(mapRegister, byteBuffer, EID, 1, PASSWORD));
-        assertFalse(validate(mapRegister, byteBuffer, EID, 1, WRONG_PASSWORD));
+        assertTrue(validate(mapRegister, byteBuffer, EID, Uint16.ONE, PASSWORD));
+        assertFalse(validate(mapRegister, byteBuffer, EID, Uint16.ONE, WRONG_PASSWORD));
     }
 
     @Test
@@ -106,8 +105,8 @@ public class LispAuthenticationTest extends BaseTestCase {
                 .getInstance()
                 .deserialize(byteBuffer, null);
 
-        assertTrue(validate(mapRegister, byteBuffer, EID, 2, PASSWORD));
-        assertFalse(validate(mapRegister, byteBuffer, EID, 2, WRONG_PASSWORD));
+        assertTrue(validate(mapRegister, byteBuffer, EID, Uint16.TWO, PASSWORD));
+        assertFalse(validate(mapRegister, byteBuffer, EID, Uint16.TWO, WRONG_PASSWORD));
     }
 
     @Test
@@ -129,8 +128,8 @@ public class LispAuthenticationTest extends BaseTestCase {
                 + "ff 00 00 05 00 01 c0 a8 88 0a");
         MapRegister mapRegister = MapRegisterSerializer.getInstance().deserialize(byteBuffer, null);
 
-        assertTrue(validate(mapRegister, byteBuffer, EID, 0, PASSWORD));
-        assertTrue(validate(mapRegister, byteBuffer, EID, 0, WRONG_PASSWORD));
+        assertTrue(validate(mapRegister, byteBuffer, EID, Uint16.ZERO, PASSWORD));
+        assertTrue(validate(mapRegister, byteBuffer, EID, Uint16.ZERO, WRONG_PASSWORD));
     }
 
     // @Test
@@ -185,15 +184,16 @@ public class LispAuthenticationTest extends BaseTestCase {
         etlrBuilder.setEid(LispAddressUtil.asIpv4PrefixEid("1.1.1.1/32"));
         etlrBuilder.setRecordTtl(55);
         mapNotifyBuilder.getMappingRecordItem().add(
-                new MappingRecordItemBuilder().setMappingRecord(etlrBuilder.build()).build());
+                new MappingRecordItemBuilder().setMappingRecord(etlrBuilder.build()).setMappingRecordItemId("xyzzy")
+                    .build());
         final ByteBuffer serializedMapNotifyMsg = MapNotifySerializer.getInstance().serialize(mapNotifyBuilder.build());
-        ArrayAssert.assertEquals(new byte[0], LispAuthenticationUtil.createAuthenticationData(serializedMapNotifyMsg,
+        assertArrayEquals(new byte[0], LispAuthenticationUtil.createAuthenticationData(serializedMapNotifyMsg,
                 "password"));
 
     }
 
-    private static boolean validate(MapRegister mapRegister, ByteBuffer byteBuffer, Eid eid, int keyId, String
-            password) {
+    private static boolean validate(final MapRegister mapRegister, final ByteBuffer byteBuffer, final Eid eid,
+            final Uint16 keyId, final String password) {
         MappingAuthkey key = new MappingAuthkeyBuilder().setKeyType(keyId).setKeyString(password).build();
         return LispAuthenticationUtil.validate(mapRegister,byteBuffer, eid, key);
     }