Add unit test for LISP address to check obj equality & construction

This commit adds various unit tests of LISP addresses in a way to
check object equality and construction.
This commit also makes minor changes to existing LISP address
classes to allow the test cases to pass all unit tests.

Change-Id: Ice9f9634bdd243baaf1eed1539ea8d5808dda01d
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
new file mode 100644
index 0000000..b8b600c
--- /dev/null
+++ b/protocols/lisp/msg/src/test/java/org/onosproject/lisp/msg/types/LispAppDataLcafAddressTest.java
@@ -0,0 +1,66 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.lisp.msg.types;
+
+import com.google.common.testing.EqualsTester;
+import org.junit.Before;
+import org.junit.Test;
+import org.onlab.packet.IpAddress;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.is;
+
+/**
+ * Unit tests for LispAppDataLcafAddress class.
+ */
+public class LispAppDataLcafAddressTest {
+
+    private LispAppDataLcafAddress address1;
+    private LispAppDataLcafAddress sameAsAddress1;
+    private LispAppDataLcafAddress address2;
+
+    @Before
+    public void setup() {
+
+        LispAfiAddress ipv4Address1 = new LispIpv4Address(IpAddress.valueOf("192.168.1.1"));
+        address1 = new LispAppDataLcafAddress((byte) 0x01, 1, (short) 10, (short) 20, ipv4Address1);
+
+        sameAsAddress1 = new LispAppDataLcafAddress((byte) 0x01, 1, (short) 10, (short) 20, ipv4Address1);
+
+        LispAfiAddress ipv4Address2 = new LispIpv4Address(IpAddress.valueOf("192.168.2.1"));
+        address2 = new LispAppDataLcafAddress((byte) 0x02, 2, (short) 20, (short) 40, ipv4Address2);
+    }
+
+    @Test
+    public void testEquality() {
+        new EqualsTester()
+                .addEqualityGroup(address1, sameAsAddress1)
+                .addEqualityGroup(address2).testEquals();
+    }
+
+    @Test
+    public void testConstruction() {
+        LispAppDataLcafAddress appDataLcafAddress = address1;
+
+        LispAfiAddress ipv4Address = new LispIpv4Address(IpAddress.valueOf("192.168.1.1"));
+
+        assertThat(appDataLcafAddress.getProtocol(), is((byte) 0x01));
+        assertThat(appDataLcafAddress.getIpTos(), is(1));
+        assertThat(appDataLcafAddress.getLocalPort(), is((short) 10));
+        assertThat(appDataLcafAddress.getRemotePort(), is((short) 20));
+        assertThat(appDataLcafAddress.getAddress(), is(ipv4Address));
+    }
+}
diff --git a/protocols/lisp/msg/src/test/java/org/onosproject/lisp/msg/types/LispAsAddressTest.java b/protocols/lisp/msg/src/test/java/org/onosproject/lisp/msg/types/LispAsAddressTest.java
new file mode 100644
index 0000000..836f340
--- /dev/null
+++ b/protocols/lisp/msg/src/test/java/org/onosproject/lisp/msg/types/LispAsAddressTest.java
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.lisp.msg.types;
+
+import com.google.common.testing.EqualsTester;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.is;
+
+/**
+ * Unit tests for LispAsAddress class.
+ */
+public class LispAsAddressTest {
+
+    private LispAsAddress address1;
+    private LispAsAddress sameAsAddress1;
+    private LispAsAddress address2;
+
+    @Before
+    public void setup() {
+
+        address1 = new LispAsAddress(1);
+        sameAsAddress1 = new LispAsAddress(1);
+        address2 = new LispAsAddress(2);
+    }
+
+    @Test
+    public void testEquality() {
+        new EqualsTester()
+                .addEqualityGroup(address1, sameAsAddress1)
+                .addEqualityGroup(address2).testEquals();
+    }
+
+    @Test
+    public void testConstruction() {
+        LispAsAddress asAddress = address1;
+        assertThat(asAddress.getASNum(), is(1));
+    }
+}
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
new file mode 100644
index 0000000..074b0ca
--- /dev/null
+++ b/protocols/lisp/msg/src/test/java/org/onosproject/lisp/msg/types/LispDistinguishedNameAddressTest.java
@@ -0,0 +1,55 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.lisp.msg.types;
+
+import com.google.common.testing.EqualsTester;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.is;
+
+/**
+ * Unit tests for LispDistinguishedNameAddress class.
+ */
+public class LispDistinguishedNameAddressTest {
+
+    private LispDistinguishedNameAddress address1;
+    private LispDistinguishedNameAddress sameAsAddress1;
+    private LispDistinguishedNameAddress address2;
+
+    @Before
+    public void setup() {
+
+        address1 = new LispDistinguishedNameAddress("distAddress1");
+        sameAsAddress1 = new LispDistinguishedNameAddress("distAddress1");
+        address2 = new LispDistinguishedNameAddress("distAddress2");
+    }
+
+    @Test
+    public void testEquality() {
+        new EqualsTester()
+                .addEqualityGroup(address1, sameAsAddress1)
+                .addEqualityGroup(address2).testEquals();
+    }
+
+    @Test
+    public void testConstruction() {
+        LispDistinguishedNameAddress distinguishedNameAddress = address1;
+
+        assertThat(distinguishedNameAddress.getDistinguishedName(), is("distAddress1"));
+    }
+}
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
new file mode 100644
index 0000000..099a7c1
--- /dev/null
+++ b/protocols/lisp/msg/src/test/java/org/onosproject/lisp/msg/types/LispIpv4AddressTest.java
@@ -0,0 +1,55 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.lisp.msg.types;
+
+import com.google.common.testing.EqualsTester;
+import org.junit.Before;
+import org.junit.Test;
+import org.onlab.packet.IpAddress;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.is;
+
+/**
+ * Unit tests for LispIpv4Address class.
+ */
+public class LispIpv4AddressTest {
+
+    private LispIpv4Address address1;
+    private LispIpv4Address sameAsAddress1;
+    private LispIpv4Address address2;
+
+    @Before
+    public void setup() {
+
+        address1 = new LispIpv4Address(IpAddress.valueOf("192.168.1.1"));
+        sameAsAddress1 = new LispIpv4Address(IpAddress.valueOf("192.168.1.1"));
+        address2 = new LispIpv4Address(IpAddress.valueOf("192.168.2.1"));
+    }
+
+    @Test
+    public void testEquality() {
+        new EqualsTester()
+                .addEqualityGroup(address1, sameAsAddress1)
+                .addEqualityGroup(address2).testEquals();
+    }
+
+    @Test
+    public void testConstruction() {
+        LispIpv4Address ipv4Address = address1;
+        assertThat(ipv4Address.getAddress(), is(IpAddress.valueOf("192.168.1.1")));
+    }
+}
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
new file mode 100644
index 0000000..d78b247
--- /dev/null
+++ b/protocols/lisp/msg/src/test/java/org/onosproject/lisp/msg/types/LispIpv6AddressTest.java
@@ -0,0 +1,55 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.lisp.msg.types;
+
+import com.google.common.testing.EqualsTester;
+import org.junit.Before;
+import org.junit.Test;
+import org.onlab.packet.IpAddress;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.is;
+
+/**
+ * Unit tests for LispIpv6Address class.
+ */
+public class LispIpv6AddressTest {
+
+    private LispIpv6Address address1;
+    private LispIpv6Address sameAsAddress1;
+    private LispIpv6Address address2;
+
+    @Before
+    public void setup() {
+
+        address1 = new LispIpv6Address(IpAddress.valueOf("1111:2222:3333:4444:5555:6666:7777:8885"));
+        sameAsAddress1 = new LispIpv6Address(IpAddress.valueOf("1111:2222:3333:4444:5555:6666:7777:8885"));
+        address2 = new LispIpv6Address(IpAddress.valueOf("1111:2222:3333:4444:5555:6666:7777:8886"));
+    }
+
+    @Test
+    public void testEquality() {
+        new EqualsTester()
+                .addEqualityGroup(address1, sameAsAddress1)
+                .addEqualityGroup(address2).testEquals();
+    }
+
+    @Test
+    public void testConstruction() {
+        LispIpv6Address ipv6Address = address1;
+        assertThat(ipv6Address.getAddress(), is(IpAddress.valueOf("1111:2222:3333:4444:5555:6666:7777:8885")));
+    }
+}
diff --git a/protocols/lisp/msg/src/test/java/org/onosproject/lisp/msg/types/LispLcafAddressTest.java b/protocols/lisp/msg/src/test/java/org/onosproject/lisp/msg/types/LispLcafAddressTest.java
new file mode 100644
index 0000000..99077d1
--- /dev/null
+++ b/protocols/lisp/msg/src/test/java/org/onosproject/lisp/msg/types/LispLcafAddressTest.java
@@ -0,0 +1,62 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.lisp.msg.types;
+
+import com.google.common.testing.EqualsTester;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.is;
+
+/**
+ * Unit tests for LispLcafAddress class.
+ */
+public class LispLcafAddressTest {
+
+    private LispLcafAddress address1;
+    private LispLcafAddress sameAsAddress1;
+    private LispLcafAddress address2;
+
+    @Before
+    public void setup() {
+
+        address1 = new LispLcafAddress(LispCanonicalAddressFormatEnum.NAT,
+                (byte) 0x01, (byte) 0x01, (byte) 0x01, (byte) 0x01);
+        sameAsAddress1 = new LispLcafAddress(LispCanonicalAddressFormatEnum.NAT,
+                (byte) 0x01, (byte) 0x01, (byte) 0x01, (byte) 0x01);
+        address2 = new LispLcafAddress(LispCanonicalAddressFormatEnum.NAT,
+                (byte) 0x02, (byte) 0x02, (byte) 0x02, (byte) 0x02);
+    }
+
+    @Test
+    public void testEquality() {
+        new EqualsTester()
+                .addEqualityGroup(address1, sameAsAddress1)
+                .addEqualityGroup(address2).testEquals();
+    }
+
+    @Test
+    public void testConstruction() {
+        LispLcafAddress lcafAddress = address1;
+
+        assertThat(lcafAddress.getType(), is(LispCanonicalAddressFormatEnum.NAT));
+        assertThat(lcafAddress.getReserved1(), is((byte) 0x01));
+        assertThat(lcafAddress.getReserved2(), is((byte) 0x01));
+        assertThat(lcafAddress.getFlag(), is((byte) 0x01));
+        assertThat(lcafAddress.getLength(), is((byte) 0x01));
+    }
+}
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
new file mode 100644
index 0000000..070ae73
--- /dev/null
+++ b/protocols/lisp/msg/src/test/java/org/onosproject/lisp/msg/types/LispListLcafAddressTest.java
@@ -0,0 +1,82 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.lisp.msg.types;
+
+import com.google.common.collect.Lists;
+import com.google.common.testing.EqualsTester;
+import org.junit.Before;
+import org.junit.Test;
+import org.onlab.packet.IpAddress;
+
+import java.util.List;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.is;
+
+/**
+ * Unit tests for LispListLcafAddress class.
+ */
+public class LispListLcafAddressTest {
+
+    private LispListLcafAddress address1;
+    private LispListLcafAddress sameAsAddress1;
+    private LispListLcafAddress address2;
+
+    @Before
+    public void setup() {
+
+        LispAfiAddress ipv4Address1 = new LispIpv4Address(IpAddress.valueOf("192.168.1.1"));
+        LispAfiAddress ipv6Address1 = new LispIpv6Address(IpAddress.valueOf("1111:2222:3333:4444:5555:6666:7777:8885"));
+
+        List<LispAfiAddress> afiAddresses1 = Lists.newArrayList();
+        afiAddresses1.add(ipv4Address1);
+        afiAddresses1.add(ipv6Address1);
+
+        address1 = new LispListLcafAddress(afiAddresses1);
+
+        sameAsAddress1 = new LispListLcafAddress(afiAddresses1);
+
+        LispAfiAddress ipv4Address2 = new LispIpv4Address(IpAddress.valueOf("192.168.2.1"));
+        LispAfiAddress ipv6Address2 = new LispIpv6Address(IpAddress.valueOf("1111:2222:3333:4444:5555:6666:7777:8886"));
+
+        List<LispAfiAddress> afiAddresses2 = Lists.newArrayList();
+        afiAddresses2.add(ipv4Address2);
+        afiAddresses2.add(ipv6Address2);
+
+        address2 = new LispListLcafAddress(afiAddresses2);
+    }
+
+    @Test
+    public void testEquality() {
+        new EqualsTester()
+                .addEqualityGroup(address1, sameAsAddress1)
+                .addEqualityGroup(address2).testEquals();
+    }
+
+    @Test
+    public void testConstruction() {
+        LispListLcafAddress listLcafAddress = address1;
+
+        LispAfiAddress ipv4Address1 = new LispIpv4Address(IpAddress.valueOf("192.168.1.1"));
+        LispAfiAddress ipv6Address1 = new LispIpv6Address(IpAddress.valueOf("1111:2222:3333:4444:5555:6666:7777:8885"));
+
+        List<LispAfiAddress> afiAddresses1 = Lists.newArrayList();
+        afiAddresses1.add(ipv4Address1);
+        afiAddresses1.add(ipv6Address1);
+
+        assertThat(listLcafAddress.getAddresses(), is(afiAddresses1));
+    }
+}
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
new file mode 100644
index 0000000..f77a306
--- /dev/null
+++ b/protocols/lisp/msg/src/test/java/org/onosproject/lisp/msg/types/LispMacAddressTest.java
@@ -0,0 +1,55 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.lisp.msg.types;
+
+import com.google.common.testing.EqualsTester;
+import org.junit.Before;
+import org.junit.Test;
+import org.onlab.packet.MacAddress;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.is;
+
+/**
+ * Unit tests for LispMacAddress class.
+ */
+public class LispMacAddressTest {
+
+    private LispMacAddress address1;
+    private LispMacAddress sameAsAddress1;
+    private LispMacAddress address2;
+
+    @Before
+    public void setup() {
+
+        address1 = new LispMacAddress(MacAddress.valueOf("00:00:00:00:00:01"));
+        sameAsAddress1 = new LispMacAddress(MacAddress.valueOf("00:00:00:00:00:01"));
+        address2 = new LispMacAddress(MacAddress.valueOf("00:00:00:00:00:02"));
+    }
+
+    @Test
+    public void testEquality() {
+        new EqualsTester()
+                .addEqualityGroup(address1, sameAsAddress1)
+                .addEqualityGroup(address2).testEquals();
+    }
+
+    @Test
+    public void testConstruction() {
+        LispMacAddress macAddress = address1;
+        assertThat(macAddress.getAddress(), is(MacAddress.valueOf("00:00:00:00:00:01")));
+    }
+}
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
new file mode 100644
index 0000000..8931de8
--- /dev/null
+++ b/protocols/lisp/msg/src/test/java/org/onosproject/lisp/msg/types/LispSegmentLcafAddressTest.java
@@ -0,0 +1,64 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.lisp.msg.types;
+
+import com.google.common.testing.EqualsTester;
+import org.junit.Before;
+import org.junit.Test;
+import org.onlab.packet.IpAddress;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.is;
+
+/**
+ * Unit tests for LispSegmentLcafAddress class.
+ */
+public class LispSegmentLcafAddressTest {
+
+    private LispSegmentLcafAddress address1;
+    private LispSegmentLcafAddress sameAsAddress1;
+    private LispSegmentLcafAddress address2;
+
+    @Before
+    public void setup() {
+
+        LispIpv4Address ipv4Address1 = new LispIpv4Address(IpAddress.valueOf("192.168.1.1"));
+        address1 = new LispSegmentLcafAddress((byte) 0x01, 1, ipv4Address1);
+
+        sameAsAddress1 = new LispSegmentLcafAddress((byte) 0x01, 1, ipv4Address1);
+
+        LispIpv4Address ipv4Address2 = new LispIpv4Address(IpAddress.valueOf("192.168.2.1"));
+        address2 = new LispSegmentLcafAddress((byte) 0x02, 2, ipv4Address2);
+    }
+
+    @Test
+    public void testEquality() {
+        new EqualsTester()
+                .addEqualityGroup(address1, sameAsAddress1)
+                .addEqualityGroup(address2).testEquals();
+    }
+
+    @Test
+    public void testConstruction() {
+        LispSegmentLcafAddress segmentLcafAddress = address1;
+
+        LispIpv4Address ipv4Address = new LispIpv4Address(IpAddress.valueOf("192.168.1.1"));
+
+        assertThat(segmentLcafAddress.getIdMaskLength(), is((byte) 0x01));
+        assertThat(segmentLcafAddress.getInstanceId(), is(1));
+        assertThat(segmentLcafAddress.getAddress(), is(ipv4Address));
+    }
+}
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
new file mode 100644
index 0000000..8296b43
--- /dev/null
+++ b/protocols/lisp/msg/src/test/java/org/onosproject/lisp/msg/types/LispSourceDestLcafAddressTest.java
@@ -0,0 +1,74 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.lisp.msg.types;
+
+import com.google.common.testing.EqualsTester;
+import org.junit.Before;
+import org.junit.Test;
+import org.onlab.packet.IpAddress;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.is;
+
+/**
+ * Unit tests for LispSourceDestLcafAddress class.
+ */
+public class LispSourceDestLcafAddressTest {
+
+    private LispSourceDestLcafAddress address1;
+    private LispSourceDestLcafAddress sameAsAddress1;
+    private LispSourceDestLcafAddress address2;
+
+    @Before
+    public void setup() {
+
+        LispIpv4Address srcAddress1 = new LispIpv4Address(IpAddress.valueOf("192.168.1.1"));
+        LispIpv4Address dstAddress1 = new LispIpv4Address(IpAddress.valueOf("192.168.1.2"));
+
+        address1 = new LispSourceDestLcafAddress((short) 1, (byte) 0x01,
+                                        (byte) 0x01, srcAddress1, dstAddress1);
+
+        sameAsAddress1 = new LispSourceDestLcafAddress((short) 1, (byte) 0x01,
+                                        (byte) 0x01, srcAddress1, dstAddress1);
+
+        LispIpv4Address srcAddress2 = new LispIpv4Address(IpAddress.valueOf("192.168.2.1"));
+        LispIpv4Address dstAddress2 = new LispIpv4Address(IpAddress.valueOf("192.168.2.2"));
+
+        address2 = new LispSourceDestLcafAddress((short) 2, (byte) 0x02,
+                                        (byte) 0x02, srcAddress2, dstAddress2);
+    }
+
+    @Test
+    public void testEquality() {
+        new EqualsTester()
+                .addEqualityGroup(address1, sameAsAddress1)
+                .addEqualityGroup(address2).testEquals();
+    }
+
+    @Test
+    public void testConstruction() {
+        LispSourceDestLcafAddress sourceDestLcafAddress = address1;
+
+        LispIpv4Address srcAddress = new LispIpv4Address(IpAddress.valueOf("192.168.1.1"));
+        LispIpv4Address dstAddress = new LispIpv4Address(IpAddress.valueOf("192.168.1.2"));
+
+        assertThat(sourceDestLcafAddress.getReserved(), is((short) 1));
+        assertThat(sourceDestLcafAddress.getSrcMaskLength(), is((byte) 0x01));
+        assertThat(sourceDestLcafAddress.getDstMaskLength(), is((byte) 0x01));
+        assertThat(sourceDestLcafAddress.getSrcPrefix(), is(srcAddress));
+        assertThat(sourceDestLcafAddress.getDstPrefix(), is(dstAddress));
+    }
+}