Imported Upstream version 4.3.2.467

Former-commit-id: 9c2cb47f45fa221e661ab616387c9cda183f283d
This commit is contained in:
Xamarin Public Jenkins
2016-02-22 11:00:01 -05:00
parent f302175246
commit f3e3aab35a
4097 changed files with 122406 additions and 82300 deletions

View File

@ -13,6 +13,7 @@ using System;
using System.Collections;
using System.IO;
using System.Net;
using System.Reflection;
using System.Threading;
namespace MonoTests.System.Net
@ -205,6 +206,36 @@ public class ServicePointTest
}
}
[Test]
public void DnsRefreshTimeout ()
{
const int dnsRefreshTimeout = 2000;
ServicePoint sp;
IPHostEntry host0, host1, host2;
Uri uri;
PropertyInfo hostEntryProperty;
ServicePointManager.DnsRefreshTimeout = dnsRefreshTimeout;
uri = new Uri ("http://www.google.com/");
sp = ServicePointManager.FindServicePoint (uri);
hostEntryProperty = typeof (ServicePoint).GetProperty ("HostEntry", BindingFlags.NonPublic | BindingFlags.Instance);
host0 = hostEntryProperty.GetValue (sp, null) as IPHostEntry;
host1 = hostEntryProperty.GetValue (sp, null) as IPHostEntry;
Assert.AreSame (host0, host1, "HostEntry should result in the same IPHostEntry object.");
Thread.Sleep (dnsRefreshTimeout * 2);
host2 = hostEntryProperty.GetValue (sp, null) as IPHostEntry;
Assert.AreNotSame(host0, host2, "HostEntry should result in a new IPHostEntry " +
"object when DnsRefreshTimeout is reached.");
}
// Debug code not used now, but could be useful later
/*
private void WriteServicePoint (string label, ServicePoint sp)