You've already forked linux-packaging-mono
Imported Upstream version 4.8.0.309
Former-commit-id: 5f9c6ae75f295e057a7d2971f3a6df4656fa8850
This commit is contained in:
parent
ee1447783b
commit
94b2861243
@ -13,7 +13,7 @@ using System;
|
||||
using System.Collections;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Reflection;
|
||||
using System.Reflection;
|
||||
using System.Threading;
|
||||
|
||||
namespace MonoTests.System.Net
|
||||
@ -23,6 +23,8 @@ namespace MonoTests.System.Net
|
||||
public class ServicePointTest
|
||||
{
|
||||
static private int max;
|
||||
|
||||
#if !FEATURE_NO_BSD_SOCKETS
|
||||
[SetUp]
|
||||
public void SaveMax () {
|
||||
max = ServicePointManager.MaxServicePoints;
|
||||
@ -33,6 +35,7 @@ public class ServicePointTest
|
||||
public void RestoreMax () {
|
||||
ServicePointManager.MaxServicePoints = max;
|
||||
}
|
||||
#endif
|
||||
|
||||
[Test]
|
||||
[Category ("InetAccess")]
|
||||
@ -54,13 +57,13 @@ public class ServicePointTest
|
||||
HttpWebRequest req = (HttpWebRequest) WebRequest.Create ("http://www.google.com");
|
||||
HttpWebResponse res = (HttpWebResponse) req.GetResponse ();
|
||||
|
||||
#if FOUND_SOME_OTHER_URL
|
||||
// URL is no longer found, disabled the test until a more reliable URL is found :P
|
||||
#if FOUND_SOME_OTHER_URL
|
||||
// URL is no longer found, disabled the test until a more reliable URL is found :P
|
||||
//WriteServicePoint ("google after getting a response", google);
|
||||
ServicePoint google2 = ServicePointManager.FindServicePoint (new Uri ("http://www.google.com/dilbert.html"));
|
||||
Assert.AreEqual (google, google2, "#equals");
|
||||
res.Close ();
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// in both instances property CurrentConnections is 0 according to ms.net.
|
||||
// let's see what it says when we do async operations...
|
||||
@ -87,8 +90,8 @@ public class ServicePointTest
|
||||
//Console.WriteLine ("ContentLength: " + res2.ContentLength);
|
||||
res2.Close ();
|
||||
|
||||
ServicePoint sp2;
|
||||
#if FOUND_SOME_OTHER_URL
|
||||
ServicePoint sp2;
|
||||
#if FOUND_SOME_OTHER_URL
|
||||
// unless of course some buffering is taking place.. let's check
|
||||
Uri uri2 = new Uri ("http://freedesktop.org/Software/pkgconfig/releases/pkgconfig-0.15.0.tar.gz");
|
||||
sp2 = ServicePointManager.FindServicePoint (uri2);
|
||||
@ -102,7 +105,7 @@ public class ServicePointTest
|
||||
// and so it shows
|
||||
//Console.WriteLine ("ContentLength: " + res2.ContentLength);
|
||||
res2.Close ();
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
// what's the limit of the cache?
|
||||
@ -154,7 +157,7 @@ public class ServicePointTest
|
||||
|
||||
[Test]
|
||||
[Category ("InetAccess")]
|
||||
[Category ("AndroidNotWorking")] // #A1 fails
|
||||
[Category ("AndroidNotWorking")] // #A1 fails
|
||||
public void EndPointBind ()
|
||||
{
|
||||
Uri uri = new Uri ("http://www.go-mono.com/");
|
||||
@ -189,6 +192,10 @@ public class ServicePointTest
|
||||
}
|
||||
|
||||
[Test] //Covers #19823
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
// This test uses HttpWebRequest
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#endif
|
||||
public void CloseConnectionGroupConcurency ()
|
||||
{
|
||||
// Try with multiple service points
|
||||
@ -206,36 +213,37 @@ 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://localhost/");
|
||||
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.");
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
[Category ("RequiresBSDSockets")] // Tests internals, so it doesn't make sense to assert that PlatformNotSupportedExceptions are thrown.
|
||||
public void DnsRefreshTimeout ()
|
||||
{
|
||||
const int dnsRefreshTimeout = 2000;
|
||||
|
||||
ServicePoint sp;
|
||||
IPHostEntry host0, host1, host2;
|
||||
Uri uri;
|
||||
PropertyInfo hostEntryProperty;
|
||||
|
||||
ServicePointManager.DnsRefreshTimeout = dnsRefreshTimeout;
|
||||
|
||||
uri = new Uri ("http://localhost/");
|
||||
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)
|
||||
|
Reference in New Issue
Block a user