Committed by
Thomas Vachuska
Improve unit test coverage by considering MapRecord and EidRecord
Change-Id: I156d9ce8a4c3becedb188a53b6ce1b8f24a5e41b
Showing
7 changed files
with
119 additions
and
24 deletions
| ... | @@ -232,6 +232,7 @@ public final class DefaultLispMapReply implements LispMapReply { | ... | @@ -232,6 +232,7 @@ public final class DefaultLispMapReply implements LispMapReply { |
| 232 | .withIsEtr(etr) | 232 | .withIsEtr(etr) |
| 233 | .withIsSecurity(security) | 233 | .withIsSecurity(security) |
| 234 | .withNonce(nonce) | 234 | .withNonce(nonce) |
| 235 | + .withMapRecords(mapRecords) | ||
| 235 | .build(); | 236 | .build(); |
| 236 | } | 237 | } |
| 237 | } | 238 | } | ... | ... |
| ... | @@ -77,7 +77,8 @@ public final class LispEidRecord { | ... | @@ -77,7 +77,8 @@ public final class LispEidRecord { |
| 77 | // let's skip the reserved field | 77 | // let's skip the reserved field |
| 78 | byteBuf.skipBytes(RESERVED_SKIP_LENGTH); | 78 | byteBuf.skipBytes(RESERVED_SKIP_LENGTH); |
| 79 | 79 | ||
| 80 | - short maskLength = (short) byteBuf.readUnsignedShort(); | 80 | + // mask length -> 8 bits |
| 81 | + short maskLength = byteBuf.readUnsignedByte(); | ||
| 81 | 82 | ||
| 82 | LispAfiAddress prefix = new LispAfiAddress.AfiAddressReader().readFrom(byteBuf); | 83 | LispAfiAddress prefix = new LispAfiAddress.AfiAddressReader().readFrom(byteBuf); |
| 83 | 84 | ... | ... |
| ... | @@ -15,18 +15,25 @@ | ... | @@ -15,18 +15,25 @@ |
| 15 | */ | 15 | */ |
| 16 | package org.onosproject.lisp.msg.protocols; | 16 | package org.onosproject.lisp.msg.protocols; |
| 17 | 17 | ||
| 18 | +import com.google.common.collect.ImmutableList; | ||
| 18 | import com.google.common.testing.EqualsTester; | 19 | import com.google.common.testing.EqualsTester; |
| 19 | import io.netty.buffer.ByteBuf; | 20 | import io.netty.buffer.ByteBuf; |
| 20 | import io.netty.buffer.Unpooled; | 21 | import io.netty.buffer.Unpooled; |
| 21 | import org.junit.Before; | 22 | import org.junit.Before; |
| 22 | import org.junit.Test; | 23 | import org.junit.Test; |
| 24 | +import org.onlab.packet.IpAddress; | ||
| 23 | import org.onosproject.lisp.msg.exceptions.LispParseError; | 25 | import org.onosproject.lisp.msg.exceptions.LispParseError; |
| 24 | import org.onosproject.lisp.msg.exceptions.LispReaderException; | 26 | import org.onosproject.lisp.msg.exceptions.LispReaderException; |
| 25 | import org.onosproject.lisp.msg.exceptions.LispWriterException; | 27 | import org.onosproject.lisp.msg.exceptions.LispWriterException; |
| 28 | +import org.onosproject.lisp.msg.protocols.LispMapRecord.MapRecordBuilder; | ||
| 29 | +import org.onosproject.lisp.msg.types.LispIpv4Address; | ||
| 30 | + | ||
| 31 | +import java.util.List; | ||
| 26 | 32 | ||
| 27 | import static org.hamcrest.MatcherAssert.assertThat; | 33 | import static org.hamcrest.MatcherAssert.assertThat; |
| 28 | import static org.hamcrest.Matchers.is; | 34 | import static org.hamcrest.Matchers.is; |
| 29 | import static org.onosproject.lisp.msg.protocols.DefaultLispMapNotify.*; | 35 | import static org.onosproject.lisp.msg.protocols.DefaultLispMapNotify.*; |
| 36 | +import static org.onosproject.lisp.msg.protocols.DefaultLispMapRecord.DefaultMapRecordBuilder; | ||
| 30 | 37 | ||
| 31 | /** | 38 | /** |
| 32 | * Unit tests for DefaultLispMapNotify class. | 39 | * Unit tests for DefaultLispMapNotify class. |
| ... | @@ -40,23 +47,29 @@ public final class DefaultLispMapNotifyTest { | ... | @@ -40,23 +47,29 @@ public final class DefaultLispMapNotifyTest { |
| 40 | @Before | 47 | @Before |
| 41 | public void setup() { | 48 | public void setup() { |
| 42 | 49 | ||
| 43 | - LispMapNotify.NotifyBuilder builder1 = | 50 | + NotifyBuilder builder1 = |
| 44 | new DefaultNotifyBuilder(); | 51 | new DefaultNotifyBuilder(); |
| 45 | 52 | ||
| 53 | + List<LispMapRecord> records1 = ImmutableList.of(getMapRecord(), getMapRecord()); | ||
| 54 | + | ||
| 46 | notify1 = builder1 | 55 | notify1 = builder1 |
| 47 | .withKeyId((short) 1) | 56 | .withKeyId((short) 1) |
| 48 | .withNonce(1L) | 57 | .withNonce(1L) |
| 58 | + .withMapRecords(records1) | ||
| 49 | .build(); | 59 | .build(); |
| 50 | 60 | ||
| 51 | - LispMapNotify.NotifyBuilder builder2 = | 61 | + NotifyBuilder builder2 = |
| 52 | new DefaultNotifyBuilder(); | 62 | new DefaultNotifyBuilder(); |
| 53 | 63 | ||
| 64 | + List<LispMapRecord> records2 = ImmutableList.of(getMapRecord(), getMapRecord()); | ||
| 65 | + | ||
| 54 | sameAsNotify1 = builder2 | 66 | sameAsNotify1 = builder2 |
| 55 | .withKeyId((short) 1) | 67 | .withKeyId((short) 1) |
| 56 | .withNonce(1L) | 68 | .withNonce(1L) |
| 69 | + .withMapRecords(records2) | ||
| 57 | .build(); | 70 | .build(); |
| 58 | 71 | ||
| 59 | - LispMapNotify.NotifyBuilder builder3 = | 72 | + NotifyBuilder builder3 = |
| 60 | new DefaultNotifyBuilder(); | 73 | new DefaultNotifyBuilder(); |
| 61 | 74 | ||
| 62 | notify2 = builder3 | 75 | notify2 = builder3 |
| ... | @@ -65,6 +78,21 @@ public final class DefaultLispMapNotifyTest { | ... | @@ -65,6 +78,21 @@ public final class DefaultLispMapNotifyTest { |
| 65 | .build(); | 78 | .build(); |
| 66 | } | 79 | } |
| 67 | 80 | ||
| 81 | + private LispMapRecord getMapRecord() { | ||
| 82 | + MapRecordBuilder builder1 = new DefaultMapRecordBuilder(); | ||
| 83 | + | ||
| 84 | + LispIpv4Address ipv4Locator1 = new LispIpv4Address(IpAddress.valueOf("192.168.1.1")); | ||
| 85 | + | ||
| 86 | + return builder1 | ||
| 87 | + .withRecordTtl(100) | ||
| 88 | + .withAuthoritative(true) | ||
| 89 | + .withMapVersionNumber((short) 1) | ||
| 90 | + .withMaskLength((byte) 0x01) | ||
| 91 | + .withAction(LispMapReplyAction.NativelyForward) | ||
| 92 | + .withEidPrefixAfi(ipv4Locator1) | ||
| 93 | + .build(); | ||
| 94 | + } | ||
| 95 | + | ||
| 68 | @Test | 96 | @Test |
| 69 | public void testEquality() { | 97 | public void testEquality() { |
| 70 | new EqualsTester() | 98 | new EqualsTester() |
| ... | @@ -78,6 +106,7 @@ public final class DefaultLispMapNotifyTest { | ... | @@ -78,6 +106,7 @@ public final class DefaultLispMapNotifyTest { |
| 78 | 106 | ||
| 79 | assertThat(notify.getKeyId(), is((short) 1)); | 107 | assertThat(notify.getKeyId(), is((short) 1)); |
| 80 | assertThat(notify.getNonce(), is(1L)); | 108 | assertThat(notify.getNonce(), is(1L)); |
| 109 | + assertThat(notify.getRecordCount(), is(2)); | ||
| 81 | } | 110 | } |
| 82 | 111 | ||
| 83 | @Test | 112 | @Test | ... | ... |
| ... | @@ -42,8 +42,7 @@ public final class DefaultLispMapRecordTest { | ... | @@ -42,8 +42,7 @@ public final class DefaultLispMapRecordTest { |
| 42 | @Before | 42 | @Before |
| 43 | public void setup() { | 43 | public void setup() { |
| 44 | 44 | ||
| 45 | - LispMapRecord.MapRecordBuilder builder1 = | 45 | + MapRecordBuilder builder1 = new DefaultMapRecordBuilder(); |
| 46 | - new DefaultMapRecordBuilder(); | ||
| 47 | 46 | ||
| 48 | LispIpv4Address ipv4Locator1 = new LispIpv4Address(IpAddress.valueOf("192.168.1.1")); | 47 | LispIpv4Address ipv4Locator1 = new LispIpv4Address(IpAddress.valueOf("192.168.1.1")); |
| 49 | 48 | ||
| ... | @@ -56,8 +55,7 @@ public final class DefaultLispMapRecordTest { | ... | @@ -56,8 +55,7 @@ public final class DefaultLispMapRecordTest { |
| 56 | .withEidPrefixAfi(ipv4Locator1) | 55 | .withEidPrefixAfi(ipv4Locator1) |
| 57 | .build(); | 56 | .build(); |
| 58 | 57 | ||
| 59 | - LispMapRecord.MapRecordBuilder builder2 = | 58 | + MapRecordBuilder builder2 = new DefaultMapRecordBuilder(); |
| 60 | - new DefaultMapRecordBuilder(); | ||
| 61 | 59 | ||
| 62 | sameAsRecord1 = builder2 | 60 | sameAsRecord1 = builder2 |
| 63 | .withRecordTtl(100) | 61 | .withRecordTtl(100) |
| ... | @@ -68,8 +66,7 @@ public final class DefaultLispMapRecordTest { | ... | @@ -68,8 +66,7 @@ public final class DefaultLispMapRecordTest { |
| 68 | .withEidPrefixAfi(ipv4Locator1) | 66 | .withEidPrefixAfi(ipv4Locator1) |
| 69 | .build(); | 67 | .build(); |
| 70 | 68 | ||
| 71 | - LispMapRecord.MapRecordBuilder builder3 = | 69 | + MapRecordBuilder builder3 = new DefaultMapRecordBuilder(); |
| 72 | - new DefaultMapRecordBuilder(); | ||
| 73 | 70 | ||
| 74 | LispIpv4Address ipv4Locator2 = new LispIpv4Address(IpAddress.valueOf("192.168.1.2")); | 71 | LispIpv4Address ipv4Locator2 = new LispIpv4Address(IpAddress.valueOf("192.168.1.2")); |
| 75 | 72 | ... | ... |
| ... | @@ -15,19 +15,28 @@ | ... | @@ -15,19 +15,28 @@ |
| 15 | */ | 15 | */ |
| 16 | package org.onosproject.lisp.msg.protocols; | 16 | package org.onosproject.lisp.msg.protocols; |
| 17 | 17 | ||
| 18 | +import com.google.common.collect.ImmutableList; | ||
| 18 | import com.google.common.testing.EqualsTester; | 19 | import com.google.common.testing.EqualsTester; |
| 19 | import io.netty.buffer.ByteBuf; | 20 | import io.netty.buffer.ByteBuf; |
| 20 | import io.netty.buffer.Unpooled; | 21 | import io.netty.buffer.Unpooled; |
| 21 | import org.junit.Before; | 22 | import org.junit.Before; |
| 22 | import org.junit.Test; | 23 | import org.junit.Test; |
| 24 | +import org.onlab.packet.IpAddress; | ||
| 23 | import org.onosproject.lisp.msg.exceptions.LispParseError; | 25 | import org.onosproject.lisp.msg.exceptions.LispParseError; |
| 24 | import org.onosproject.lisp.msg.exceptions.LispReaderException; | 26 | import org.onosproject.lisp.msg.exceptions.LispReaderException; |
| 25 | import org.onosproject.lisp.msg.exceptions.LispWriterException; | 27 | import org.onosproject.lisp.msg.exceptions.LispWriterException; |
| 26 | import org.onosproject.lisp.msg.protocols.DefaultLispMapRegister.RegisterReader; | 28 | import org.onosproject.lisp.msg.protocols.DefaultLispMapRegister.RegisterReader; |
| 27 | import org.onosproject.lisp.msg.protocols.DefaultLispMapRegister.RegisterWriter; | 29 | import org.onosproject.lisp.msg.protocols.DefaultLispMapRegister.RegisterWriter; |
| 30 | +import org.onosproject.lisp.msg.protocols.LispMapRecord.MapRecordBuilder; | ||
| 31 | +import org.onosproject.lisp.msg.protocols.LispMapRegister.RegisterBuilder; | ||
| 32 | +import org.onosproject.lisp.msg.types.LispIpv4Address; | ||
| 33 | + | ||
| 34 | +import java.util.List; | ||
| 28 | 35 | ||
| 29 | import static org.hamcrest.MatcherAssert.assertThat; | 36 | import static org.hamcrest.MatcherAssert.assertThat; |
| 30 | import static org.hamcrest.Matchers.is; | 37 | import static org.hamcrest.Matchers.is; |
| 38 | +import static org.onosproject.lisp.msg.protocols.DefaultLispMapRecord.DefaultMapRecordBuilder; | ||
| 39 | +import static org.onosproject.lisp.msg.protocols.DefaultLispMapRegister.DefaultRegisterBuilder; | ||
| 31 | 40 | ||
| 32 | /** | 41 | /** |
| 33 | * Unit tests for DefaultLispMapRegister class. | 42 | * Unit tests for DefaultLispMapRegister class. |
| ... | @@ -41,28 +50,31 @@ public final class DefaultLispMapRegisterTest { | ... | @@ -41,28 +50,31 @@ public final class DefaultLispMapRegisterTest { |
| 41 | @Before | 50 | @Before |
| 42 | public void setup() { | 51 | public void setup() { |
| 43 | 52 | ||
| 44 | - LispMapRegister.RegisterBuilder builder1 = | 53 | + RegisterBuilder builder1 = new DefaultRegisterBuilder(); |
| 45 | - new DefaultLispMapRegister.DefaultRegisterBuilder(); | 54 | + |
| 55 | + List<LispMapRecord> records1 = ImmutableList.of(getMapRecord(), getMapRecord()); | ||
| 46 | 56 | ||
| 47 | register1 = builder1 | 57 | register1 = builder1 |
| 48 | .withIsProxyMapReply(true) | 58 | .withIsProxyMapReply(true) |
| 49 | .withIsWantMapNotify(false) | 59 | .withIsWantMapNotify(false) |
| 50 | .withKeyId((short) 1) | 60 | .withKeyId((short) 1) |
| 51 | .withNonce(1L) | 61 | .withNonce(1L) |
| 62 | + .withMapRecords(records1) | ||
| 52 | .build(); | 63 | .build(); |
| 53 | 64 | ||
| 54 | - LispMapRegister.RegisterBuilder builder2 = | 65 | + RegisterBuilder builder2 = new DefaultRegisterBuilder(); |
| 55 | - new DefaultLispMapRegister.DefaultRegisterBuilder(); | 66 | + |
| 67 | + List<LispMapRecord> records2 = ImmutableList.of(getMapRecord(), getMapRecord()); | ||
| 56 | 68 | ||
| 57 | sameAsRegister1 = builder2 | 69 | sameAsRegister1 = builder2 |
| 58 | .withIsProxyMapReply(true) | 70 | .withIsProxyMapReply(true) |
| 59 | .withIsWantMapNotify(false) | 71 | .withIsWantMapNotify(false) |
| 60 | .withKeyId((short) 1) | 72 | .withKeyId((short) 1) |
| 61 | .withNonce(1L) | 73 | .withNonce(1L) |
| 74 | + .withMapRecords(records2) | ||
| 62 | .build(); | 75 | .build(); |
| 63 | 76 | ||
| 64 | - LispMapRegister.RegisterBuilder builder3 = | 77 | + RegisterBuilder builder3 = new DefaultRegisterBuilder(); |
| 65 | - new DefaultLispMapRegister.DefaultRegisterBuilder(); | ||
| 66 | 78 | ||
| 67 | register2 = builder3 | 79 | register2 = builder3 |
| 68 | .withIsProxyMapReply(true) | 80 | .withIsProxyMapReply(true) |
| ... | @@ -72,6 +84,21 @@ public final class DefaultLispMapRegisterTest { | ... | @@ -72,6 +84,21 @@ public final class DefaultLispMapRegisterTest { |
| 72 | .build(); | 84 | .build(); |
| 73 | } | 85 | } |
| 74 | 86 | ||
| 87 | + private LispMapRecord getMapRecord() { | ||
| 88 | + MapRecordBuilder builder1 = new DefaultMapRecordBuilder(); | ||
| 89 | + | ||
| 90 | + LispIpv4Address ipv4Locator1 = new LispIpv4Address(IpAddress.valueOf("192.168.1.1")); | ||
| 91 | + | ||
| 92 | + return builder1 | ||
| 93 | + .withRecordTtl(100) | ||
| 94 | + .withAuthoritative(true) | ||
| 95 | + .withMapVersionNumber((short) 1) | ||
| 96 | + .withMaskLength((byte) 0x01) | ||
| 97 | + .withAction(LispMapReplyAction.NativelyForward) | ||
| 98 | + .withEidPrefixAfi(ipv4Locator1) | ||
| 99 | + .build(); | ||
| 100 | + } | ||
| 101 | + | ||
| 75 | @Test | 102 | @Test |
| 76 | public void testEquality() { | 103 | public void testEquality() { |
| 77 | new EqualsTester() | 104 | new EqualsTester() |
| ... | @@ -87,6 +114,7 @@ public final class DefaultLispMapRegisterTest { | ... | @@ -87,6 +114,7 @@ public final class DefaultLispMapRegisterTest { |
| 87 | assertThat(register.isWantMapNotify(), is(false)); | 114 | assertThat(register.isWantMapNotify(), is(false)); |
| 88 | assertThat(register.getKeyId(), is((short) 1)); | 115 | assertThat(register.getKeyId(), is((short) 1)); |
| 89 | assertThat(register.getNonce(), is(1L)); | 116 | assertThat(register.getNonce(), is(1L)); |
| 117 | + assertThat(register.getRecordCount(), is(2)); | ||
| 90 | } | 118 | } |
| 91 | 119 | ||
| 92 | @Test | 120 | @Test | ... | ... |
| ... | @@ -15,19 +15,28 @@ | ... | @@ -15,19 +15,28 @@ |
| 15 | */ | 15 | */ |
| 16 | package org.onosproject.lisp.msg.protocols; | 16 | package org.onosproject.lisp.msg.protocols; |
| 17 | 17 | ||
| 18 | +import com.google.common.collect.ImmutableList; | ||
| 18 | import com.google.common.testing.EqualsTester; | 19 | import com.google.common.testing.EqualsTester; |
| 19 | import io.netty.buffer.ByteBuf; | 20 | import io.netty.buffer.ByteBuf; |
| 20 | import io.netty.buffer.Unpooled; | 21 | import io.netty.buffer.Unpooled; |
| 21 | import org.junit.Before; | 22 | import org.junit.Before; |
| 22 | import org.junit.Test; | 23 | import org.junit.Test; |
| 24 | +import org.onlab.packet.IpAddress; | ||
| 23 | import org.onosproject.lisp.msg.exceptions.LispParseError; | 25 | import org.onosproject.lisp.msg.exceptions.LispParseError; |
| 24 | import org.onosproject.lisp.msg.exceptions.LispReaderException; | 26 | import org.onosproject.lisp.msg.exceptions.LispReaderException; |
| 25 | import org.onosproject.lisp.msg.exceptions.LispWriterException; | 27 | import org.onosproject.lisp.msg.exceptions.LispWriterException; |
| 26 | import org.onosproject.lisp.msg.protocols.DefaultLispMapReply.ReplyReader; | 28 | import org.onosproject.lisp.msg.protocols.DefaultLispMapReply.ReplyReader; |
| 27 | import org.onosproject.lisp.msg.protocols.DefaultLispMapReply.ReplyWriter; | 29 | import org.onosproject.lisp.msg.protocols.DefaultLispMapReply.ReplyWriter; |
| 30 | +import org.onosproject.lisp.msg.types.LispIpv4Address; | ||
| 31 | + | ||
| 32 | +import java.util.List; | ||
| 28 | 33 | ||
| 29 | import static org.hamcrest.MatcherAssert.assertThat; | 34 | import static org.hamcrest.MatcherAssert.assertThat; |
| 30 | import static org.hamcrest.Matchers.is; | 35 | import static org.hamcrest.Matchers.is; |
| 36 | +import static org.onosproject.lisp.msg.protocols.DefaultLispMapRecord.DefaultMapRecordBuilder; | ||
| 37 | +import static org.onosproject.lisp.msg.protocols.DefaultLispMapRecord.MapRecordBuilder; | ||
| 38 | +import static org.onosproject.lisp.msg.protocols.DefaultLispMapReply.DefaultReplyBuilder; | ||
| 39 | +import static org.onosproject.lisp.msg.protocols.DefaultLispMapReply.ReplyBuilder; | ||
| 31 | 40 | ||
| 32 | /** | 41 | /** |
| 33 | * Unit tests for DefaultLispMapReply class. | 42 | * Unit tests for DefaultLispMapReply class. |
| ... | @@ -41,28 +50,32 @@ public final class DefaultLispMapReplyTest { | ... | @@ -41,28 +50,32 @@ public final class DefaultLispMapReplyTest { |
| 41 | @Before | 50 | @Before |
| 42 | public void setup() { | 51 | public void setup() { |
| 43 | 52 | ||
| 44 | - LispMapReply.ReplyBuilder builder1 = | 53 | + ReplyBuilder builder1 = new DefaultReplyBuilder(); |
| 45 | - new DefaultLispMapReply.DefaultReplyBuilder(); | 54 | + |
| 55 | + List<LispMapRecord> records1 = ImmutableList.of(getMapRecord(), getMapRecord()); | ||
| 46 | 56 | ||
| 47 | reply1 = builder1 | 57 | reply1 = builder1 |
| 48 | .withIsEtr(true) | 58 | .withIsEtr(true) |
| 49 | .withIsProbe(false) | 59 | .withIsProbe(false) |
| 50 | .withIsSecurity(true) | 60 | .withIsSecurity(true) |
| 51 | .withNonce(1L) | 61 | .withNonce(1L) |
| 62 | + .withMapRecords(records1) | ||
| 52 | .build(); | 63 | .build(); |
| 53 | 64 | ||
| 54 | - LispMapReply.ReplyBuilder builder2 = | 65 | + ReplyBuilder builder2 = new DefaultReplyBuilder(); |
| 55 | - new DefaultLispMapReply.DefaultReplyBuilder(); | 66 | + |
| 67 | + List<LispMapRecord> records2 = ImmutableList.of(getMapRecord(), getMapRecord()); | ||
| 56 | 68 | ||
| 57 | sameAsReply1 = builder2 | 69 | sameAsReply1 = builder2 |
| 58 | .withIsEtr(true) | 70 | .withIsEtr(true) |
| 59 | .withIsProbe(false) | 71 | .withIsProbe(false) |
| 60 | .withIsSecurity(true) | 72 | .withIsSecurity(true) |
| 61 | .withNonce(1L) | 73 | .withNonce(1L) |
| 74 | + .withMapRecords(records2) | ||
| 62 | .build(); | 75 | .build(); |
| 63 | 76 | ||
| 64 | - LispMapReply.ReplyBuilder builder3 = | 77 | + ReplyBuilder builder3 = new DefaultReplyBuilder(); |
| 65 | - new DefaultLispMapReply.DefaultReplyBuilder(); | 78 | + |
| 66 | reply2 = builder3 | 79 | reply2 = builder3 |
| 67 | .withIsEtr(false) | 80 | .withIsEtr(false) |
| 68 | .withIsProbe(true) | 81 | .withIsProbe(true) |
| ... | @@ -71,6 +84,21 @@ public final class DefaultLispMapReplyTest { | ... | @@ -71,6 +84,21 @@ public final class DefaultLispMapReplyTest { |
| 71 | .build(); | 84 | .build(); |
| 72 | } | 85 | } |
| 73 | 86 | ||
| 87 | + private LispMapRecord getMapRecord() { | ||
| 88 | + MapRecordBuilder builder1 = new DefaultMapRecordBuilder(); | ||
| 89 | + | ||
| 90 | + LispIpv4Address ipv4Locator1 = new LispIpv4Address(IpAddress.valueOf("192.168.1.1")); | ||
| 91 | + | ||
| 92 | + return builder1 | ||
| 93 | + .withRecordTtl(100) | ||
| 94 | + .withAuthoritative(true) | ||
| 95 | + .withMapVersionNumber((short) 1) | ||
| 96 | + .withMaskLength((byte) 0x01) | ||
| 97 | + .withAction(LispMapReplyAction.NativelyForward) | ||
| 98 | + .withEidPrefixAfi(ipv4Locator1) | ||
| 99 | + .build(); | ||
| 100 | + } | ||
| 101 | + | ||
| 74 | @Test | 102 | @Test |
| 75 | public void testEquality() { | 103 | public void testEquality() { |
| 76 | new EqualsTester() | 104 | new EqualsTester() |
| ... | @@ -86,6 +114,7 @@ public final class DefaultLispMapReplyTest { | ... | @@ -86,6 +114,7 @@ public final class DefaultLispMapReplyTest { |
| 86 | assertThat(reply.isProbe(), is(false)); | 114 | assertThat(reply.isProbe(), is(false)); |
| 87 | assertThat(reply.isSecurity(), is(true)); | 115 | assertThat(reply.isSecurity(), is(true)); |
| 88 | assertThat(reply.getNonce(), is(1L)); | 116 | assertThat(reply.getNonce(), is(1L)); |
| 117 | + assertThat(reply.getRecordCount(), is(2)); | ||
| 89 | } | 118 | } |
| 90 | 119 | ||
| 91 | @Test | 120 | @Test | ... | ... |
| ... | @@ -54,6 +54,7 @@ public final class DefaultLispMapRequestTest { | ... | @@ -54,6 +54,7 @@ public final class DefaultLispMapRequestTest { |
| 54 | LispIpv4Address ipv4Rloc2 = new LispIpv4Address(IpAddress.valueOf("10.1.1.2")); | 54 | LispIpv4Address ipv4Rloc2 = new LispIpv4Address(IpAddress.valueOf("10.1.1.2")); |
| 55 | 55 | ||
| 56 | List<LispAfiAddress> rlocs1 = ImmutableList.of(ipv4Rloc1, ipv4Rloc2); | 56 | List<LispAfiAddress> rlocs1 = ImmutableList.of(ipv4Rloc1, ipv4Rloc2); |
| 57 | + List<LispEidRecord> records1 = ImmutableList.of(getEidRecord(), getEidRecord()); | ||
| 57 | 58 | ||
| 58 | request1 = builder1 | 59 | request1 = builder1 |
| 59 | .withIsAuthoritative(true) | 60 | .withIsAuthoritative(true) |
| ... | @@ -64,10 +65,12 @@ public final class DefaultLispMapRequestTest { | ... | @@ -64,10 +65,12 @@ public final class DefaultLispMapRequestTest { |
| 64 | .withIsSmrInvoked(false) | 65 | .withIsSmrInvoked(false) |
| 65 | .withSourceEid(ipv4Eid1) | 66 | .withSourceEid(ipv4Eid1) |
| 66 | .withItrRlocs(rlocs1) | 67 | .withItrRlocs(rlocs1) |
| 68 | + .withEidRecords(records1) | ||
| 67 | .withNonce(1L) | 69 | .withNonce(1L) |
| 68 | .build(); | 70 | .build(); |
| 69 | 71 | ||
| 70 | RequestBuilder builder2 = new DefaultRequestBuilder(); | 72 | RequestBuilder builder2 = new DefaultRequestBuilder(); |
| 73 | + List<LispEidRecord> records2 = ImmutableList.of(getEidRecord(), getEidRecord()); | ||
| 71 | 74 | ||
| 72 | sameAsRequest1 = builder2 | 75 | sameAsRequest1 = builder2 |
| 73 | .withIsAuthoritative(true) | 76 | .withIsAuthoritative(true) |
| ... | @@ -78,6 +81,7 @@ public final class DefaultLispMapRequestTest { | ... | @@ -78,6 +81,7 @@ public final class DefaultLispMapRequestTest { |
| 78 | .withIsSmrInvoked(false) | 81 | .withIsSmrInvoked(false) |
| 79 | .withSourceEid(ipv4Eid1) | 82 | .withSourceEid(ipv4Eid1) |
| 80 | .withItrRlocs(rlocs1) | 83 | .withItrRlocs(rlocs1) |
| 84 | + .withEidRecords(records2) | ||
| 81 | .withNonce(1L) | 85 | .withNonce(1L) |
| 82 | .build(); | 86 | .build(); |
| 83 | 87 | ||
| ... | @@ -85,8 +89,8 @@ public final class DefaultLispMapRequestTest { | ... | @@ -85,8 +89,8 @@ public final class DefaultLispMapRequestTest { |
| 85 | 89 | ||
| 86 | LispIpv4Address ipv4Eid2 = new LispIpv4Address(IpAddress.valueOf("192.168.1.2")); | 90 | LispIpv4Address ipv4Eid2 = new LispIpv4Address(IpAddress.valueOf("192.168.1.2")); |
| 87 | 91 | ||
| 88 | - LispIpv4Address ipv4Rloc3 = new LispIpv4Address(IpAddress.valueOf("10.1.1.1")); | 92 | + LispIpv4Address ipv4Rloc3 = new LispIpv4Address(IpAddress.valueOf("20.1.1.1")); |
| 89 | - LispIpv4Address ipv4Rloc4 = new LispIpv4Address(IpAddress.valueOf("10.1.1.2")); | 93 | + LispIpv4Address ipv4Rloc4 = new LispIpv4Address(IpAddress.valueOf("20.1.1.2")); |
| 90 | 94 | ||
| 91 | List<LispAfiAddress> rlocs2 = ImmutableList.of(ipv4Rloc3, ipv4Rloc4); | 95 | List<LispAfiAddress> rlocs2 = ImmutableList.of(ipv4Rloc3, ipv4Rloc4); |
| 92 | 96 | ||
| ... | @@ -103,6 +107,11 @@ public final class DefaultLispMapRequestTest { | ... | @@ -103,6 +107,11 @@ public final class DefaultLispMapRequestTest { |
| 103 | .build(); | 107 | .build(); |
| 104 | } | 108 | } |
| 105 | 109 | ||
| 110 | + private LispEidRecord getEidRecord() { | ||
| 111 | + LispIpv4Address eid = new LispIpv4Address(IpAddress.valueOf("20.1.1.1")); | ||
| 112 | + return new LispEidRecord((byte) 24, eid); | ||
| 113 | + } | ||
| 114 | + | ||
| 106 | @Test | 115 | @Test |
| 107 | public void testEquality() { | 116 | public void testEquality() { |
| 108 | new EqualsTester() | 117 | new EqualsTester() |
| ... | @@ -121,6 +130,7 @@ public final class DefaultLispMapRequestTest { | ... | @@ -121,6 +130,7 @@ public final class DefaultLispMapRequestTest { |
| 121 | assertThat(request.isSmr(), is(true)); | 130 | assertThat(request.isSmr(), is(true)); |
| 122 | assertThat(request.isSmrInvoked(), is(false)); | 131 | assertThat(request.isSmrInvoked(), is(false)); |
| 123 | assertThat(request.getNonce(), is(1L)); | 132 | assertThat(request.getNonce(), is(1L)); |
| 133 | + assertThat(request.getRecordCount(), is(2)); | ||
| 124 | } | 134 | } |
| 125 | 135 | ||
| 126 | @Test | 136 | @Test | ... | ... |
-
Please register or login to post a comment