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/LispSegmentLcafAddressTest.java b/protocols/lisp/msg/src/test/java/org/onosproject/lisp/msg/types/LispSegmentLcafAddressTest.java
index b1f811c..eda8f0a 100644
--- a/protocols/lisp/msg/src/test/java/org/onosproject/lisp/msg/types/LispSegmentLcafAddressTest.java
+++ b/protocols/lisp/msg/src/test/java/org/onosproject/lisp/msg/types/LispSegmentLcafAddressTest.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.LispSegmentLcafAddress.SegmentLcafAddressReader;
+import static org.onosproject.lisp.msg.types.LispSegmentLcafAddress.SegmentLcafAddressWriter;
/**
* Unit tests for LispSegmentLcafAddress class.
@@ -83,4 +90,18 @@
assertThat(segmentLcafAddress.getInstanceId(), is(1));
assertThat(segmentLcafAddress.getAddress(), is(ipv4Address));
}
+
+ @Test
+ public void testSerialization() throws LispWriterException, LispParseError, LispReaderException {
+ ByteBuf byteBuf = Unpooled.buffer();
+
+ SegmentLcafAddressWriter writer = new SegmentLcafAddressWriter();
+ writer.writeTo(byteBuf, address1);
+
+ SegmentLcafAddressReader reader = new SegmentLcafAddressReader();
+ LispSegmentLcafAddress deserialized = reader.readFrom(byteBuf);
+
+ new EqualsTester()
+ .addEqualityGroup(address1, deserialized).testEquals();
+ }
}