Add unit tests for LISP address serializer and deserializer
Change-Id: I56538221f3951d18c1feb9343d87cbb46c3ed04d
diff --git a/protocols/lisp/msg/src/test/java/org/onosproject/lisp/msg/types/LispDistinguishedNameAddressTest.java b/protocols/lisp/msg/src/test/java/org/onosproject/lisp/msg/types/LispDistinguishedNameAddressTest.java
index 074b0ca..fc2a160 100644
--- a/protocols/lisp/msg/src/test/java/org/onosproject/lisp/msg/types/LispDistinguishedNameAddressTest.java
+++ b/protocols/lisp/msg/src/test/java/org/onosproject/lisp/msg/types/LispDistinguishedNameAddressTest.java
@@ -16,12 +16,18 @@
package org.onosproject.lisp.msg.types;
import com.google.common.testing.EqualsTester;
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
import org.junit.Before;
import org.junit.Test;
+import org.onosproject.lisp.msg.exceptions.LispParseError;
+import org.onosproject.lisp.msg.exceptions.LispWriterException;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
+import static org.onosproject.lisp.msg.types.LispDistinguishedNameAddress.*;
+
/**
* Unit tests for LispDistinguishedNameAddress class.
*/
@@ -52,4 +58,18 @@
assertThat(distinguishedNameAddress.getDistinguishedName(), is("distAddress1"));
}
+
+ @Test
+ public void testSerialization() throws LispWriterException, LispParseError {
+ ByteBuf byteBuf = Unpooled.buffer();
+
+ DistinguishedNameAddressWriter writer = new DistinguishedNameAddressWriter();
+ writer.writeTo(byteBuf, address1);
+
+ DistinguishedNameAddressReader reader = new DistinguishedNameAddressReader();
+ LispDistinguishedNameAddress deserialized = reader.readFrom(byteBuf);
+
+ new EqualsTester()
+ .addEqualityGroup(address1, deserialized).testEquals();
+ }
}