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/LispMacAddressTest.java b/protocols/lisp/msg/src/test/java/org/onosproject/lisp/msg/types/LispMacAddressTest.java
index f77a306..f28c7f6 100644
--- a/protocols/lisp/msg/src/test/java/org/onosproject/lisp/msg/types/LispMacAddressTest.java
+++ b/protocols/lisp/msg/src/test/java/org/onosproject/lisp/msg/types/LispMacAddressTest.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.onlab.packet.MacAddress;
+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.LispMacAddress.MacAddressReader;
+import static org.onosproject.lisp.msg.types.LispMacAddress.MacAddressWriter;
/**
* Unit tests for LispMacAddress class.
@@ -52,4 +58,18 @@
LispMacAddress macAddress = address1;
assertThat(macAddress.getAddress(), is(MacAddress.valueOf("00:00:00:00:00:01")));
}
+
+ @Test
+ public void testSerialization() throws LispWriterException, LispParseError {
+ ByteBuf byteBuf = Unpooled.buffer();
+
+ MacAddressWriter writer = new MacAddressWriter();
+ writer.writeTo(byteBuf, address1);
+
+ MacAddressReader reader = new MacAddressReader();
+ LispMacAddress deserialized = reader.readFrom(byteBuf);
+
+ new EqualsTester()
+ .addEqualityGroup(address1, deserialized).testEquals();
+ }
}