Add unit tests for LISP address serializer and deserializer
Change-Id: I56538221f3951d18c1feb9343d87cbb46c3ed04d
diff --git a/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/types/LispAfiAddress.java b/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/types/LispAfiAddress.java
index 1d88008..c7e72c5 100644
--- a/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/types/LispAfiAddress.java
+++ b/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/types/LispAfiAddress.java
@@ -126,6 +126,10 @@
@Override
public void writeTo(ByteBuf byteBuf, LispAfiAddress address) throws LispWriterException {
+
+ // AFI code
+ byteBuf.writeShort(address.getAfi().getIanaCode());
+
switch (address.getAfi()) {
case IP:
new LispIpAddress.IpAddressWriter().writeTo(byteBuf, (LispIpv4Address) address);
diff --git a/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/types/LispAppDataLcafAddress.java b/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/types/LispAppDataLcafAddress.java
index 284ebe4..56ff2f2 100644
--- a/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/types/LispAppDataLcafAddress.java
+++ b/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/types/LispAppDataLcafAddress.java
@@ -21,6 +21,7 @@
import org.onosproject.lisp.msg.exceptions.LispWriterException;
import java.nio.ByteBuffer;
+import java.util.Arrays;
import java.util.Objects;
import static com.google.common.base.MoreObjects.toStringHelper;
@@ -352,7 +353,7 @@
}
/**
- * A utility function that obtains the partial int value from byte arrays.
+ * An utility function that obtains the partial int value from byte arrays.
*
* @param bytes an array of bytes
* @return converted integer
@@ -378,8 +379,8 @@
LispLcafAddress.serializeCommon(byteBuf, address);
- // TODO: need to handle TOS
-
+ byte[] tos = getPartialByteArray(address.getIpTos());
+ byteBuf.writeBytes(tos);
byteBuf.writeByte(address.getProtocol());
byteBuf.writeShort(address.getLocalPortLow());
byteBuf.writeShort(address.getLocalPortHigh());
@@ -389,5 +390,17 @@
AfiAddressWriter writer = new LispAfiAddress.AfiAddressWriter();
writer.writeTo(byteBuf, address.getAddress());
}
+
+ /**
+ * An utility function that obtains byte array from partial int value.
+ *
+ * @param value integer value
+ * @return an array of bytes
+ */
+ public static byte[] getPartialByteArray(int value) {
+ ByteBuffer buffer = ByteBuffer.allocate(4);
+ byte[] array = buffer.putInt(value).array();
+ return Arrays.copyOfRange(array, 1, 4);
+ }
}
}
diff --git a/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/types/LispDistinguishedNameAddress.java b/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/types/LispDistinguishedNameAddress.java
index 77f1c08..d4be998 100644
--- a/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/types/LispDistinguishedNameAddress.java
+++ b/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/types/LispDistinguishedNameAddress.java
@@ -84,10 +84,10 @@
public LispDistinguishedNameAddress readFrom(ByteBuf byteBuf) throws LispParseError {
StringBuilder sb = new StringBuilder();
- byte character = byteBuf.readByte();
- while (character != 0) {
- sb.append((char) character);
+ byte character;
+ while (byteBuf.readerIndex() < byteBuf.writerIndex()) {
character = byteBuf.readByte();
+ sb.append((char) character);
}
return new LispDistinguishedNameAddress(sb.toString());
@@ -105,7 +105,7 @@
String distinguishedName = address.getDistinguishedName();
byte[] nameBytes = distinguishedName.getBytes();
for (int i = 0; i < nameBytes.length; i++) {
- byteBuf.writeChar(nameBytes[i]);
+ byteBuf.writeByte(nameBytes[i]);
}
}
}
diff --git a/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/types/LispIpv6Address.java b/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/types/LispIpv6Address.java
index ed3ad43..2017174 100644
--- a/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/types/LispIpv6Address.java
+++ b/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/types/LispIpv6Address.java
@@ -35,7 +35,7 @@
* @param address IP address
*/
public LispIpv6Address(IpAddress address) {
- super(address, AddressFamilyIdentifierEnum.IP);
+ super(address, AddressFamilyIdentifierEnum.IP6);
checkArgument(address.isIp6());
}
diff --git a/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/types/LispListLcafAddress.java b/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/types/LispListLcafAddress.java
index 3552b45..68834db 100644
--- a/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/types/LispListLcafAddress.java
+++ b/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/types/LispListLcafAddress.java
@@ -128,8 +128,10 @@
LispLcafAddress lcafAddress = LispLcafAddress.deserializeCommon(byteBuf);
- LispAfiAddress ipv4 = new LispAfiAddress.AfiAddressReader().readFrom(byteBuf);
- LispAfiAddress ipv6 = new LispAfiAddress.AfiAddressReader().readFrom(byteBuf);
+ AfiAddressReader reader = new AfiAddressReader();
+
+ LispAfiAddress ipv4 = reader.readFrom(byteBuf);
+ LispAfiAddress ipv6 = reader.readFrom(byteBuf);
return new LispListLcafAddress(lcafAddress.getReserved1(), lcafAddress.getReserved2(),
lcafAddress.getFlag(), ImmutableList.of(ipv4, ipv6));
@@ -141,6 +143,9 @@
*/
public static class ListLcafAddressWriter implements LispAddressWriter<LispListLcafAddress> {
+ private static final int IPV4_ADDRESS_INDEX = 0;
+ private static final int IPV6_ADDRESS_INDEX = 1;
+
@Override
public void writeTo(ByteBuf byteBuf, LispListLcafAddress address) throws LispWriterException {
@@ -149,8 +154,16 @@
LispIpv4Address.Ipv4AddressWriter v4Writer = new LispIpv4Address.Ipv4AddressWriter();
LispIpv6Address.Ipv6AddressWriter v6Writer = new LispIpv6Address.Ipv6AddressWriter();
- v4Writer.writeTo(byteBuf, (LispIpv4Address) address.getAddresses().get(0));
- v6Writer.writeTo(byteBuf, (LispIpv6Address) address.getAddresses().get(1));
+ LispAfiAddress ipv4 = address.getAddresses().get(IPV4_ADDRESS_INDEX);
+ LispAfiAddress ipv6 = address.getAddresses().get(IPV6_ADDRESS_INDEX);
+
+ // IPv4 address
+ byteBuf.writeShort(ipv4.getAfi().getIanaCode());
+ v4Writer.writeTo(byteBuf, (LispIpv4Address) ipv4);
+
+ // IPv6 address
+ byteBuf.writeShort(ipv6.getAfi().getIanaCode());
+ v6Writer.writeTo(byteBuf, (LispIpv6Address) ipv6);
}
}
}
diff --git a/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/types/LispSegmentLcafAddress.java b/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/types/LispSegmentLcafAddress.java
index 8405695..c6a84cc 100644
--- a/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/types/LispSegmentLcafAddress.java
+++ b/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/types/LispSegmentLcafAddress.java
@@ -227,7 +227,8 @@
LispLcafAddress.serializeCommon(byteBuf, address);
byteBuf.writeInt(address.getInstanceId());
- new LispIpAddress.IpAddressWriter().writeTo(byteBuf, (LispIpAddress) address.getAddress());
+
+ new LispAfiAddress.AfiAddressWriter().writeTo(byteBuf, address.getAddress());
}
}
}
diff --git a/protocols/lisp/msg/src/test/java/org/onosproject/lisp/msg/types/LispAppDataLcafAddressTest.java b/protocols/lisp/msg/src/test/java/org/onosproject/lisp/msg/types/LispAppDataLcafAddressTest.java
index ea528a0..f9a00ee 100644
--- a/protocols/lisp/msg/src/test/java/org/onosproject/lisp/msg/types/LispAppDataLcafAddressTest.java
+++ b/protocols/lisp/msg/src/test/java/org/onosproject/lisp/msg/types/LispAppDataLcafAddressTest.java
@@ -16,12 +16,20 @@
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 org.onosproject.lisp.msg.types.LispAppDataLcafAddress.AppDataLcafAddressWriter;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
+import static org.onosproject.lisp.msg.types.LispAppDataLcafAddress.AppDataAddressBuilder;
+import static org.onosproject.lisp.msg.types.LispAppDataLcafAddress.AppDataLcafAddressReader;
/**
* Unit tests for LispAppDataLcafAddress class.
@@ -35,8 +43,8 @@
@Before
public void setup() {
- LispAppDataLcafAddress.AppDataAddressBuilder builder1 =
- new LispAppDataLcafAddress.AppDataAddressBuilder();
+ AppDataAddressBuilder builder1 =
+ new AppDataAddressBuilder();
LispAfiAddress ipv4Address1 = new LispIpv4Address(IpAddress.valueOf("192.168.1.1"));
@@ -50,8 +58,8 @@
.withAddress(ipv4Address1)
.build();
- LispAppDataLcafAddress.AppDataAddressBuilder builder2 =
- new LispAppDataLcafAddress.AppDataAddressBuilder();
+ AppDataAddressBuilder builder2 =
+ new AppDataAddressBuilder();
sameAsAddress1 = builder2
.withProtocol((byte) 0x01)
@@ -63,8 +71,8 @@
.withAddress(ipv4Address1)
.build();
- LispAppDataLcafAddress.AppDataAddressBuilder builder3 =
- new LispAppDataLcafAddress.AppDataAddressBuilder();
+ AppDataAddressBuilder builder3 =
+ new AppDataAddressBuilder();
LispAfiAddress ipv4Address2 = new LispIpv4Address(IpAddress.valueOf("192.168.2.1"));
@@ -100,4 +108,18 @@
assertThat(appDataLcafAddress.getRemotePortHigh(), is((short) 254));
assertThat(appDataLcafAddress.getAddress(), is(ipv4Address));
}
+
+ @Test
+ public void testSerialization() throws LispWriterException, LispParseError, LispReaderException {
+ ByteBuf byteBuf = Unpooled.buffer();
+
+ AppDataLcafAddressWriter writer = new AppDataLcafAddressWriter();
+ writer.writeTo(byteBuf, address1);
+
+ AppDataLcafAddressReader reader = new AppDataLcafAddressReader();
+ LispAppDataLcafAddress deserialized = reader.readFrom(byteBuf);
+
+ new EqualsTester()
+ .addEqualityGroup(address1, deserialized).testEquals();
+ }
}
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();
+ }
}
diff --git a/protocols/lisp/msg/src/test/java/org/onosproject/lisp/msg/types/LispIpv4AddressTest.java b/protocols/lisp/msg/src/test/java/org/onosproject/lisp/msg/types/LispIpv4AddressTest.java
index 099a7c1..f247a32 100644
--- a/protocols/lisp/msg/src/test/java/org/onosproject/lisp/msg/types/LispIpv4AddressTest.java
+++ b/protocols/lisp/msg/src/test/java/org/onosproject/lisp/msg/types/LispIpv4AddressTest.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.IpAddress;
+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.LispIpv4Address.Ipv4AddressReader;
+import static org.onosproject.lisp.msg.types.LispIpv4Address.Ipv4AddressWriter;
/**
* Unit tests for LispIpv4Address class.
@@ -52,4 +58,18 @@
LispIpv4Address ipv4Address = address1;
assertThat(ipv4Address.getAddress(), is(IpAddress.valueOf("192.168.1.1")));
}
+
+ @Test
+ public void testSerialization() throws LispWriterException, LispParseError {
+ ByteBuf byteBuf = Unpooled.buffer();
+
+ Ipv4AddressWriter writer = new Ipv4AddressWriter();
+ writer.writeTo(byteBuf, address1);
+
+ Ipv4AddressReader reader = new Ipv4AddressReader();
+ LispIpv4Address deserialized = reader.readFrom(byteBuf);
+
+ new EqualsTester()
+ .addEqualityGroup(address1, deserialized).testEquals();
+ }
}
diff --git a/protocols/lisp/msg/src/test/java/org/onosproject/lisp/msg/types/LispIpv6AddressTest.java b/protocols/lisp/msg/src/test/java/org/onosproject/lisp/msg/types/LispIpv6AddressTest.java
index d78b247..37ed606 100644
--- a/protocols/lisp/msg/src/test/java/org/onosproject/lisp/msg/types/LispIpv6AddressTest.java
+++ b/protocols/lisp/msg/src/test/java/org/onosproject/lisp/msg/types/LispIpv6AddressTest.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.LispWriterException;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
+import static org.onosproject.lisp.msg.types.LispIpv6Address.Ipv6AddressReader;
+import static org.onosproject.lisp.msg.types.LispIpv6Address.Ipv6AddressWriter;
+
/**
* Unit tests for LispIpv6Address class.
@@ -52,4 +59,18 @@
LispIpv6Address ipv6Address = address1;
assertThat(ipv6Address.getAddress(), is(IpAddress.valueOf("1111:2222:3333:4444:5555:6666:7777:8885")));
}
+
+ @Test
+ public void testSerialization() throws LispWriterException, LispParseError {
+ ByteBuf byteBuf = Unpooled.buffer();
+
+ Ipv6AddressWriter writer = new Ipv6AddressWriter();
+ writer.writeTo(byteBuf, address1);
+
+ Ipv6AddressReader reader = new Ipv6AddressReader();
+ LispIpv6Address deserialized = reader.readFrom(byteBuf);
+
+ new EqualsTester()
+ .addEqualityGroup(address1, deserialized).testEquals();
+ }
}
diff --git a/protocols/lisp/msg/src/test/java/org/onosproject/lisp/msg/types/LispListLcafAddressTest.java b/protocols/lisp/msg/src/test/java/org/onosproject/lisp/msg/types/LispListLcafAddressTest.java
index 070ae73..771a2a7 100644
--- a/protocols/lisp/msg/src/test/java/org/onosproject/lisp/msg/types/LispListLcafAddressTest.java
+++ b/protocols/lisp/msg/src/test/java/org/onosproject/lisp/msg/types/LispListLcafAddressTest.java
@@ -17,14 +17,21 @@
import com.google.common.collect.Lists;
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 java.util.List;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
+import static org.onosproject.lisp.msg.types.LispListLcafAddress.ListLcafAddressReader;
+import static org.onosproject.lisp.msg.types.LispListLcafAddress.ListLcafAddressWriter;
/**
* Unit tests for LispListLcafAddress class.
@@ -79,4 +86,18 @@
assertThat(listLcafAddress.getAddresses(), is(afiAddresses1));
}
+
+ @Test
+ public void testSerialization() throws LispWriterException, LispParseError, LispReaderException {
+ ByteBuf byteBuf = Unpooled.buffer();
+
+ ListLcafAddressWriter writer = new ListLcafAddressWriter();
+ writer.writeTo(byteBuf, address1);
+
+ ListLcafAddressReader reader = new ListLcafAddressReader();
+ LispListLcafAddress deserialized = reader.readFrom(byteBuf);
+
+ new EqualsTester()
+ .addEqualityGroup(address1, deserialized).testEquals();
+ }
}
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();
+ }
}
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();
+ }
}
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();
+ }
}