Remove use of junit-addons
[lispflowmapping.git] / mappingservice / lisp-proto / src / test / java / org / opendaylight / lispflowmapping / serializer / MapNotifySerializationTest.java
index c099885e9f4e5318bf9e40f246207ca399c333d9..33e62c02330e55b6d2f8b00491b057f3acc94346 100644 (file)
@@ -5,18 +5,15 @@
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
-
 package org.opendaylight.lispflowmapping.serializer;
 
+import static org.junit.Assert.assertArrayEquals;
 import static org.junit.Assert.assertEquals;
 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.serializer.exception.LispSerializationException;
@@ -26,11 +23,11 @@ import org.opendaylight.lispflowmapping.tools.junit.BaseTestCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapNotify;
 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.MappingRecord;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecord.Action;
-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.MappingRecord;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping._record.container.MappingRecord.Action;
+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;
 
 public class MapNotifySerializationTest extends BaseTestCase {
 
@@ -41,17 +38,17 @@ public class MapNotifySerializationTest extends BaseTestCase {
         mnBuilder.getMappingRecordItem().add(
                 new MappingRecordItemBuilder().setMappingRecord(
                         new MappingRecordBuilder().setEid(LispAddressUtil.asIpv4PrefixEid("0.0.0.1/32")).build())
-                        .build());
+                                .setMappingRecordItemId("xyzzy").build());
         mnBuilder.getMappingRecordItem().add(
                 new MappingRecordItemBuilder().setMappingRecord(
                         new MappingRecordBuilder().setEid(LispAddressUtil.asIpv4PrefixEid("0.0.0.73/32")).build())
-                        .build());
+                                .setMappingRecordItemId("xyzzy").build());
 
         mnBuilder.setNonce(6161616161L);
         mnBuilder.setKeyId((short) 0x0001);
         byte[] authenticationData = new byte[] { (byte) 0x16, (byte) 0x98, (byte) 0x96, (byte) 0xeb, (byte) 0x88,
-                (byte) 0x2d, (byte) 0x4d, (byte) 0x22, (byte) 0xe5, (byte) 0x8f, (byte) 0xe6, (byte) 0x89, (byte) 0x64,
-                (byte) 0xb9, (byte) 0x17, (byte) 0xa4, (byte) 0xba, (byte) 0x4e, (byte) 0x8c, (byte) 0x41 };
+            (byte) 0x2d, (byte) 0x4d, (byte) 0x22, (byte) 0xe5, (byte) 0x8f, (byte) 0xe6, (byte) 0x89, (byte) 0x64,
+            (byte) 0xb9, (byte) 0x17, (byte) 0xa4, (byte) 0xba, (byte) 0x4e, (byte) 0x8c, (byte) 0x41 };
         mnBuilder.setAuthenticationData(authenticationData);
 
         ByteBuffer bb = MapNotifySerializer.getInstance().serialize(mnBuilder.build());
@@ -64,7 +61,7 @@ public class MapNotifySerializationTest extends BaseTestCase {
 
         byte[] actualAuthenticationData = new byte[20];
         bb.get(actualAuthenticationData);
-        ArrayAssert.assertEquals(authenticationData, actualAuthenticationData);
+        assertArrayEquals(authenticationData, actualAuthenticationData);
 
         bb.position(bb.position() + 12); /* EID in first record */
         assertEquals(0x1, bb.getInt());
@@ -82,21 +79,21 @@ public class MapNotifySerializationTest extends BaseTestCase {
         mnBuilder.getMappingRecordItem().add(
                 new MappingRecordItemBuilder().setMappingRecord(
                         new MappingRecordBuilder().setEid(LispAddressUtil.asIpv4PrefixEid("0.0.0.1/32")).build())
-                        .build());
+                                .setMappingRecordItemId("xyzzy").build());
         mnBuilder.getMappingRecordItem().add(
                 new MappingRecordItemBuilder().setMappingRecord(
                         new MappingRecordBuilder().setEid(LispAddressUtil.asIpv4PrefixEid("0.0.0.73/32")).build())
-                        .build());
+                                .setMappingRecordItemId("xyzzy").build());
 
         mnBuilder.setNonce(6161616161L);
         mnBuilder.setKeyId((short) 0x0001);
         byte[] authenticationData = new byte[] { (byte) 0x16, (byte) 0x98, (byte) 0x96, (byte) 0xeb, (byte) 0x88,
-                (byte) 0x2d, (byte) 0x4d, (byte) 0x22, (byte) 0xe5, (byte) 0x8f, (byte) 0xe6, (byte) 0x89, (byte) 0x64,
-                (byte) 0xb9, (byte) 0x17, (byte) 0xa4, (byte) 0xba, (byte) 0x4e, (byte) 0x8c, (byte) 0x41 };
+            (byte) 0x2d, (byte) 0x4d, (byte) 0x22, (byte) 0xe5, (byte) 0x8f, (byte) 0xe6, (byte) 0x89, (byte) 0x64,
+            (byte) 0xb9, (byte) 0x17, (byte) 0xa4, (byte) 0xba, (byte) 0x4e, (byte) 0x8c, (byte) 0x41 };
         mnBuilder.setAuthenticationData(authenticationData);
 
         MapNotify mn = mnBuilder.build();
-        ArrayAssert.assertEquals(MapNotifySerializer.getInstance().serialize(mn).array(),
+        assertArrayEquals(MapNotifySerializer.getInstance().serialize(mn).array(),
                 MapNotifySerializer.getInstance().serialize(MapNotifySerializer.getInstance()
                         .deserialize(MapNotifySerializer.getInstance().serialize(mn))).array());
 
@@ -124,13 +121,13 @@ public class MapNotifySerializationTest extends BaseTestCase {
                 ));
 
 
-        assertTrue(mn.isXtrSiteIdPresent());
+        assertTrue(mn.getXtrSiteIdPresent());
 
         assertEquals(1, mn.getMappingRecordItem().size());
         assertEquals(0xFFBB000000000000L, mn.getNonce().longValue());
         assertEquals(0x0000, mn.getKeyId().shortValue());
         byte[] expectedAuthenticationData = {};
-        ArrayAssert.assertEquals(expectedAuthenticationData, mn.getAuthenticationData());
+        assertArrayEquals(expectedAuthenticationData, mn.getAuthenticationData());
     }
 
     @Test
@@ -140,7 +137,7 @@ public class MapNotifySerializationTest extends BaseTestCase {
         mnBuilder.getMappingRecordItem().add(
                 new MappingRecordItemBuilder().setMappingRecord(
                         new MappingRecordBuilder().setEid(LispAddressUtil.asIpv4PrefixEid("0.0.0.1/32"))
-                        .setRecordTtl(55).build()).build());
+                        .setRecordTtl(55).build()).setMappingRecordItemId("xyzzy").build());
 
         ByteBuffer bb = MapNotifySerializer.getInstance().serialize(mnBuilder.build());
         bb.position(bb.position() + 14); // jump to AuthenticationDataLength
@@ -167,11 +164,12 @@ public class MapNotifySerializationTest extends BaseTestCase {
         MapNotifyBuilder mnBuilder = new MapNotifyBuilder();
         mnBuilder.setMappingRecordItem(new ArrayList<MappingRecordItem>());
         mnBuilder.getMappingRecordItem().add(new MappingRecordItemBuilder().setMappingRecord(
-                new MappingRecordBuilder().build()).build());
-        mnBuilder.getMappingRecordItem().add(new MappingRecordItemBuilder().setMappingRecord
-                (new MappingRecordBuilder().setEid(null).build()).build());
+                new MappingRecordBuilder().build()).setMappingRecordItemId("xyzzy").build());
+        mnBuilder.getMappingRecordItem().add(new MappingRecordItemBuilder().setMappingRecord(
+                new MappingRecordBuilder().setEid(null).build()).setMappingRecordItemId("xyzzy").build());
         mnBuilder.getMappingRecordItem().add(new MappingRecordItemBuilder().setMappingRecord(
-                new MappingRecordBuilder().setEid(LispAddressUtil.getNoAddressEid()).build()).build());
+                new MappingRecordBuilder().setEid(LispAddressUtil.getNoAddressEid()).build())
+                    .setMappingRecordItemId("xyzzy").build());
 
         ByteBuffer bb = MapNotifySerializer.getInstance().serialize(mnBuilder.build());
         bb.position(bb.position() + 16); // jump to first record prefix AFI
@@ -266,17 +264,17 @@ public class MapNotifySerializationTest extends BaseTestCase {
         assertEquals((byte) 0x34, loc1.getMulticastWeight().byteValue());
         assertEquals((byte) 0xA4, loc2.getMulticastWeight().byteValue());
 
-        assertTrue(loc0.isLocalLocator());
-        assertFalse(loc1.isLocalLocator());
-        assertFalse(loc2.isLocalLocator());
+        assertTrue(loc0.getLocalLocator());
+        assertFalse(loc1.getLocalLocator());
+        assertFalse(loc2.getLocalLocator());
 
-        assertFalse(loc0.isRlocProbed());
-        assertTrue(loc1.isRlocProbed());
-        assertTrue(loc2.isRlocProbed());
+        assertFalse(loc0.getRlocProbed());
+        assertTrue(loc1.getRlocProbed());
+        assertTrue(loc2.getRlocProbed());
 
-        assertTrue(loc0.isRouted());
-        assertFalse(loc1.isRouted());
-        assertTrue(loc2.isRouted());
+        assertTrue(loc0.getRouted());
+        assertFalse(loc1.getRouted());
+        assertTrue(loc2.getRouted());
 
         assertEquals(LispAddressUtil.asIpv4Rloc("192.168.136.10"), loc0.getRloc());
         assertEquals(LispAddressUtil.asIpv4Rloc("204.170.170.17"), loc1.getRloc());
@@ -312,10 +310,10 @@ public class MapNotifySerializationTest extends BaseTestCase {
 
         assertEquals(4, mn.getMappingRecordItem().size());
 
-        MappingRecord record0 = mn.getMappingRecordItem().get(0).getMappingRecord();
-        MappingRecord record1 = mn.getMappingRecordItem().get(1).getMappingRecord();
-        MappingRecord record2 = mn.getMappingRecordItem().get(2).getMappingRecord();
-        MappingRecord record3 = mn.getMappingRecordItem().get(3).getMappingRecord();
+        final MappingRecord record0 = mn.getMappingRecordItem().get(0).getMappingRecord();
+        final MappingRecord record1 = mn.getMappingRecordItem().get(1).getMappingRecord();
+        final MappingRecord record2 = mn.getMappingRecordItem().get(2).getMappingRecord();
+        final MappingRecord record3 = mn.getMappingRecordItem().get(3).getMappingRecord();
 
         assertEquals(10, record0.getRecordTtl().intValue());
         assertEquals(13, record3.getRecordTtl().intValue());
@@ -328,10 +326,10 @@ public class MapNotifySerializationTest extends BaseTestCase {
         assertEquals(Action.NoAction, record2.getAction());
         assertEquals(Action.NativelyForward, record3.getAction());
 
-        assertTrue(record0.isAuthoritative());
-        assertTrue(record1.isAuthoritative());
-        assertFalse(record2.isAuthoritative());
-        assertFalse(record3.isAuthoritative());
+        assertTrue(record0.getAuthoritative());
+        assertTrue(record1.getAuthoritative());
+        assertFalse(record2.getAuthoritative());
+        assertFalse(record3.getAuthoritative());
 
         assertEquals(0x000, record0.getMapVersion().shortValue());
         assertEquals(0x111, record1.getMapVersion().shortValue());
@@ -390,15 +388,15 @@ public class MapNotifySerializationTest extends BaseTestCase {
                 + "00 0a 01 20 10 00 00 00 00 01 99 10 fe 01 01 64 "
                 + "ff 00 00 05 00 01 c0 a8 88 0a"));
 
-        assertFalse(mn.isXtrSiteIdPresent());
+        assertFalse(mn.getXtrSiteIdPresent());
 
         assertEquals(1, mn.getMappingRecordItem().size());
         assertEquals(0xFFBB000000000000L, mn.getNonce().longValue());
         assertEquals(0x0001, mn.getKeyId().shortValue());
         byte[] expectedAuthenticationData = { (byte) 0x2c, (byte) 0x61, (byte) 0xb9, (byte) 0xc9, (byte) 0x9a,
-                (byte) 0x20, (byte) 0xba, (byte) 0xd8, (byte) 0xf5, (byte) 0x40, (byte) 0xd3, (byte) 0x55, (byte) 0x6f,
-                (byte) 0x5f, (byte) 0x6e, (byte) 0x5a, (byte) 0xb2, (byte) 0x0a, (byte) 0xbf, (byte) 0xb5 };
-        ArrayAssert.assertEquals(expectedAuthenticationData, mn.getAuthenticationData());
+            (byte) 0x20, (byte) 0xba, (byte) 0xd8, (byte) 0xf5, (byte) 0x40, (byte) 0xd3, (byte) 0x55, (byte) 0x6f,
+            (byte) 0x5f, (byte) 0x6e, (byte) 0x5a, (byte) 0xb2, (byte) 0x0a, (byte) 0xbf, (byte) 0xb5 };
+        assertArrayEquals(expectedAuthenticationData, mn.getAuthenticationData());
     }
 
     @Test
@@ -421,16 +419,16 @@ public class MapNotifySerializationTest extends BaseTestCase {
                 + "00 0a 01 20 10 00 00 00 00 01 99 10 fe 01 01 64 "
                 + "ff 00 00 05 00 01 c0 a8 88 0a"));
 
-        assertFalse(mn.isXtrSiteIdPresent());
+        assertFalse(mn.getXtrSiteIdPresent());
 
         assertEquals(1, mn.getMappingRecordItem().size());
         assertEquals(0xFFBB000000000000L, mn.getNonce().longValue());
         assertEquals(0x0002, mn.getKeyId().shortValue());
         byte[] expectedAuthenticationData = { (byte) 0x70, (byte) 0x30, (byte) 0xd4, (byte) 0xc6, (byte) 0x10,
-                (byte) 0x44, (byte) 0x0d, (byte) 0x83, (byte) 0xbe, (byte) 0x4d, (byte) 0xbf, (byte) 0xfd, (byte) 0xa9,
-                (byte) 0x8c, (byte) 0x57, (byte) 0x6d, (byte) 0x68, (byte) 0xa5, (byte) 0xbf, (byte) 0x32, (byte) 0x11,
-                (byte) 0xc9, (byte) 0x7b, (byte) 0x58, (byte) 0xc4, (byte) 0xb9, (byte) 0x9f, (byte) 0x06, (byte) 0x11,
-                (byte) 0x23, (byte) 0xb9, (byte) 0x38 };
-        ArrayAssert.assertEquals(expectedAuthenticationData, mn.getAuthenticationData());
+            (byte) 0x44, (byte) 0x0d, (byte) 0x83, (byte) 0xbe, (byte) 0x4d, (byte) 0xbf, (byte) 0xfd, (byte) 0xa9,
+            (byte) 0x8c, (byte) 0x57, (byte) 0x6d, (byte) 0x68, (byte) 0xa5, (byte) 0xbf, (byte) 0x32, (byte) 0x11,
+            (byte) 0xc9, (byte) 0x7b, (byte) 0x58, (byte) 0xc4, (byte) 0xb9, (byte) 0x9f, (byte) 0x06, (byte) 0x11,
+            (byte) 0x23, (byte) 0xb9, (byte) 0x38 };
+        assertArrayEquals(expectedAuthenticationData, mn.getAuthenticationData());
     }
 }