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/LispSourceDestLcafAddressTest.java b/protocols/lisp/msg/src/test/java/org/onosproject/lisp/msg/types/LispSourceDestLcafAddressTest.java
index e212a1c..c3d74e4 100644
--- a/protocols/lisp/msg/src/test/java/org/onosproject/lisp/msg/types/LispSourceDestLcafAddressTest.java
+++ b/protocols/lisp/msg/src/test/java/org/onosproject/lisp/msg/types/LispSourceDestLcafAddressTest.java
@@ -16,12 +16,19 @@
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.onlab.packet.IpAddress;
+import org.onosproject.lisp.msg.exceptions.LispParseError;
+import org.onosproject.lisp.msg.exceptions.LispReaderException;
+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.LispSourceDestLcafAddress.SourceDestLcafAddressReader;
+import static org.onosproject.lisp.msg.types.LispSourceDestLcafAddress.SourceDestLcafAddressWriter;
/**
* Unit tests for LispSourceDestLcafAddress class.
@@ -95,4 +102,18 @@
assertThat(sourceDestLcafAddress.getSrcPrefix(), is(srcAddress));
assertThat(sourceDestLcafAddress.getDstPrefix(), is(dstAddress));
}
+
+ @Test
+ public void testSerialization() throws LispWriterException, LispParseError, LispReaderException {
+ ByteBuf byteBuf = Unpooled.buffer();
+
+ SourceDestLcafAddressWriter writer = new SourceDestLcafAddressWriter();
+ writer.writeTo(byteBuf, address1);
+
+ SourceDestLcafAddressReader reader = new SourceDestLcafAddressReader();
+ LispSourceDestLcafAddress deserialized = reader.readFrom(byteBuf);
+
+ new EqualsTester()
+ .addEqualityGroup(address1, deserialized).testEquals();
+ }
}