Remove use of junit-addons
[lispflowmapping.git] / mappingservice / lisp-proto / src / test / java / org / opendaylight / lispflowmapping / serializer / address / ApplicationDataSerializerTest.java
index 470615e64e4e7f2b31cf7f5777e1af20b7a2fe90..c22ff7a32172c1efad62426f5ca0f089cfd1a88c 100644 (file)
@@ -7,12 +7,10 @@
  */
 package org.opendaylight.lispflowmapping.serializer.address;
 
+import static org.junit.Assert.assertArrayEquals;
 import static org.junit.Assert.assertEquals;
 
 import java.nio.ByteBuffer;
-
-import junitx.framework.ArrayAssert;
-
 import org.junit.Test;
 import org.opendaylight.lispflowmapping.lisp.serializer.address.LispAddressSerializer;
 import org.opendaylight.lispflowmapping.lisp.serializer.exception.LispSerializationException;
@@ -23,27 +21,28 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.ApplicationDataLcaf;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.SimpleAddress;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.Address;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.ApplicationData;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.application.data.ApplicationDataBuilder;
 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.eid.container.EidBuilder;
+import org.opendaylight.yangtools.yang.common.Uint16;
+import org.opendaylight.yangtools.yang.common.Uint8;
 
 public class ApplicationDataSerializerTest extends BaseTestCase {
 
     @Test
     public void deserialize__Simple() throws Exception {
-        Eid address = LispAddressSerializer.getInstance().deserializeEid(hexToByteBuffer("40 03 00 00 " + //
-                "04 20 00 0E " + //
-                "AA BB CC DD " + // IPTOS & protocol
-                "A6 A1 A6 A2 " + // local port range
-                "FF DD FF DE " + // remote port range
-                "00 01 11 22 33 44"), null); // AFI=1, IP=0x11223344
+        Eid address = LispAddressSerializer.getInstance().deserializeEid(hexToByteBuffer("40 03 00 00 "
+                + "04 20 00 0E "
+                + "AA BB CC DD " // IPTOS & protocol
+                + "A6 A1 A6 A2 " // local port range
+                + "FF DD FF DE " // remote port range
+                "00 01 11 22 33 44"), null); // AFI=1, IP=0x11223344
 
-        assertEquals(ApplicationDataLcaf.class, address.getAddressType());
+        assertEquals(ApplicationDataLcaf.VALUE, address.getAddressType());
         ApplicationData appAddress = (ApplicationData) address.getAddress();
 
-        assertEquals("17.34.51.68", String.valueOf(appAddress.getApplicationData().getAddress().getValue()));
+        assertEquals("17.34.51.68", appAddress.getApplicationData().getAddress().stringValue());
         assertEquals(ByteUtil.getPartialInt(new byte[] { (byte) 0xAA, (byte) 0xBB, (byte) 0xCC }),
                 appAddress.getApplicationData().getIpTos().intValue());
         assertEquals((byte) 0xDD, appAddress.getApplicationData().getProtocol().byteValue());
@@ -55,63 +54,65 @@ public class ApplicationDataSerializerTest extends BaseTestCase {
 
     @Test(expected = LispSerializationException.class)
     public void deserialize__ShorterBuffer() throws Exception {
-        LispAddressSerializer.getInstance().deserializeEid(hexToByteBuffer("40 03 00 00 " + //
-                "04 20 00 0A " + //
-                "AA BB "), null);
+        LispAddressSerializer.getInstance().deserializeEid(hexToByteBuffer("""
+            40 03 00 00 \
+            04 20 00 0A \
+            AA BB \
+            """), null);
     }
 
     @Test(expected = LispSerializationException.class)
     public void deserialize__UnknownLCAFType() throws Exception {
-        LispAddressSerializer.getInstance().deserializeEid(hexToByteBuffer("40 03 00 00 " + //
-                "AA 20 00 12 " + // Type AA is unknown
-                "AA BB CC DD " + // IPTOS & protocol
-                "A6 A1 A6 A2 " + // local port range
-                "FF DD FF DE " + // remote port range
-                "00 01 11 22 33 44"), null); // AFI=1, IP=0x11223344
+        LispAddressSerializer.getInstance().deserializeEid(hexToByteBuffer("""
+            40 03 00 00 \
+            AA 20 00 12 \
+            AA BB CC DD \
+            A6 A1 A6 A2 \
+            FF DD FF DE \
+            00 01 11 22 33 44"""), null); // AFI=1, IP=0x11223344
     }
 
     @Test
     public void deserialize__Ipv6() throws Exception {
         Eid appAddress = LispAddressSerializer.getInstance().deserializeEid(
-                hexToByteBuffer("40 03 00 00 " + //
-                        "04 20 00 1E " + //
-                        "AA BB CC DD " + // IPTOS & protocol
-                        "A6 A1 A6 A2 " + // local port range
-                        "FF DD FF DE " + // remote port range
-                        "00 02 11 22 33 44 55 66 77 88 99 AA BB CC AA BB CC DD"), null); // AFI=2,
+                hexToByteBuffer("40 03 00 00 "
+                        + "04 20 00 1E "
+                        + "AA BB CC DD " // IPTOS & protocol
+                        + "A6 A1 A6 A2 " // local port range
+                        + "FF DD FF DE " // remote port range
+                        "00 02 11 22 33 44 55 66 77 88 99 AA BB CC AA BB CC DD"), null); // AFI=2,
         // IPv6
 
-        assertEquals("1122:3344:5566:7788:99aa:bbcc:aabb:ccdd", String.valueOf(
-                ((ApplicationData) appAddress.getAddress()).getApplicationData().getAddress().getValue()));
+        assertEquals("1122:3344:5566:7788:99aa:bbcc:aabb:ccdd",
+                ((ApplicationData) appAddress.getAddress()).getApplicationData().getAddress().stringValue());
     }
 
     @Test
     public void serialize__Simple() throws Exception {
-        ApplicationDataBuilder addressBuilder = new ApplicationDataBuilder();
-        addressBuilder.setIpTos(ByteUtil.getPartialInt(new byte[] { (byte) 0xAA, (byte) 0xBB, (byte) 0xCC }));
-        addressBuilder.setProtocol((short) 0xDD);
-        addressBuilder.setLocalPortLow(new PortNumber(0xA6A1));
-        addressBuilder.setLocalPortHigh(new PortNumber(0xA6A2));
-        addressBuilder.setRemotePortLow(new PortNumber(0xFFDD));
-        addressBuilder.setRemotePortHigh(new PortNumber(0xFFDE));
-        addressBuilder.setAddress(new SimpleAddress(new IpAddress(new Ipv4Address("17.34.51.68"))));
+        ApplicationDataBuilder addressBuilder = new ApplicationDataBuilder()
+            .setIpTos(ByteUtil.getPartialInt(new byte[] { (byte) 0xAA, (byte) 0xBB, (byte) 0xCC }))
+            .setProtocol(Uint8.valueOf(0xDD))
+            .setLocalPortLow(new PortNumber(Uint16.valueOf(0xA6A1)))
+            .setLocalPortHigh(new PortNumber(Uint16.valueOf(0xA6A2)))
+            .setRemotePortLow(new PortNumber(Uint16.valueOf(0xFFDD)))
+            .setRemotePortHigh(new PortNumber(Uint16.valueOf(0xFFDE)))
+            .setAddress(new SimpleAddress(new IpAddress(new Ipv4Address("17.34.51.68"))));
 
         EidBuilder eb = new EidBuilder();
-        eb.setAddressType(ApplicationDataLcaf.class);
+        eb.setAddressType(ApplicationDataLcaf.VALUE);
         eb.setVirtualNetworkId(null);
-        eb.setAddress((Address)
-                new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105
-                .lisp.address.address.ApplicationDataBuilder()
-                .setApplicationData(addressBuilder.build()).build());
+        eb.setAddress(new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105
+            .lisp.address.address.ApplicationDataBuilder()
+            .setApplicationData(addressBuilder.build()).build());
 
         ByteBuffer buf = ByteBuffer.allocate(LispAddressSerializer.getInstance().getAddressSize(eb.build()));
         LispAddressSerializer.getInstance().serialize(buf, eb.build());
-        ByteBuffer expectedBuf = hexToByteBuffer("40 03 00 00 " + //
-                "04 00 00 12 " + //
-                "AA BB CC DD " + // IPTOS & protocol
-                "A6 A1 A6 A2 " + // local port range
-                "FF DD FF DE " + // remote port range
-                "00 01 11 22 33 44"); // AFI=1, IP=0x11223344
-        ArrayAssert.assertEquals(expectedBuf.array(), buf.array());
+        ByteBuffer expectedBuf = hexToByteBuffer("40 03 00 00 "
+                + "04 00 00 12 " //
+                + "AA BB CC DD " // IPTOS & protocol
+                + "A6 A1 A6 A2 " // local port range
+                + "FF DD FF DE " // remote port range
+                "00 01 11 22 33 44"); // AFI=1, IP=0x11223344
+        assertArrayEquals(expectedBuf.array(), buf.array());
     }
 }