Merge "Add DHCP address lease expiry in IpMemoryStore."

This commit is contained in:
Xiao Ma
2019-04-01 12:59:20 +00:00
committed by Gerrit Code Review
2 changed files with 5 additions and 1 deletions

View File

@@ -44,6 +44,8 @@ public class ParcelableTests {
assertEquals(in, new NetworkAttributes(parcelingRoundTrip(in.toParcelable()))); assertEquals(in, new NetworkAttributes(parcelingRoundTrip(in.toParcelable())));
builder.setAssignedV4Address((Inet4Address) Inet4Address.getByName("1.2.3.4")); builder.setAssignedV4Address((Inet4Address) Inet4Address.getByName("1.2.3.4"));
// lease will expire in two hours
builder.setAssignedV4AddressExpiry(System.currentTimeMillis() + 7_200_000);
// groupHint stays null this time around // groupHint stays null this time around
builder.setDnsAddresses(Collections.emptyList()); builder.setDnsAddresses(Collections.emptyList());
builder.setMtu(18); builder.setMtu(18);
@@ -51,6 +53,7 @@ public class ParcelableTests {
assertEquals(in, new NetworkAttributes(parcelingRoundTrip(in.toParcelable()))); assertEquals(in, new NetworkAttributes(parcelingRoundTrip(in.toParcelable())));
builder.setAssignedV4Address((Inet4Address) Inet4Address.getByName("6.7.8.9")); builder.setAssignedV4Address((Inet4Address) Inet4Address.getByName("6.7.8.9"));
builder.setAssignedV4AddressExpiry(System.currentTimeMillis() + 3_600_000);
builder.setGroupHint("groupHint"); builder.setGroupHint("groupHint");
builder.setDnsAddresses(Arrays.asList( builder.setDnsAddresses(Arrays.asList(
InetAddress.getByName("ACA1:652B:0911:DE8F:1200:115E:913B:AA2A"), InetAddress.getByName("ACA1:652B:0911:DE8F:1200:115E:913B:AA2A"),
@@ -66,7 +69,7 @@ public class ParcelableTests {
// Verify that this test does not miss any new field added later. // Verify that this test does not miss any new field added later.
// If any field is added to NetworkAttributes it must be tested here for parceling // If any field is added to NetworkAttributes it must be tested here for parceling
// roundtrip. // roundtrip.
assertEquals(4, Arrays.stream(NetworkAttributes.class.getDeclaredFields()) assertEquals(5, Arrays.stream(NetworkAttributes.class.getDeclaredFields())
.filter(f -> !Modifier.isStatic(f.getModifiers())).count()); .filter(f -> !Modifier.isStatic(f.getModifiers())).count());
} }

View File

@@ -57,6 +57,7 @@ public class NetworkAttributesTest {
final NetworkAttributes na = final NetworkAttributes na =
new NetworkAttributes( new NetworkAttributes(
(Inet4Address) Inet4Address.getByAddress(new byte[] {1, 2, 3, 4}), (Inet4Address) Inet4Address.getByAddress(new byte[] {1, 2, 3, 4}),
System.currentTimeMillis() + 7_200_000,
"some hint", "some hint",
Arrays.asList(Inet4Address.getByAddress(new byte[] {5, 6, 7, 8}), Arrays.asList(Inet4Address.getByAddress(new byte[] {5, 6, 7, 8}),
Inet4Address.getByAddress(new byte[] {9, 0, 1, 2})), Inet4Address.getByAddress(new byte[] {9, 0, 1, 2})),