private Uri googleUri;\r
private Uri yahooUri;\r
private Uri apacheUri;\r
+ private int maxIdle;\r
\r
[SetUp]\r
public void GetReady () \r
{\r
+ maxIdle = ServicePointManager.MaxServicePointIdleTime;\r
+ ServicePointManager.MaxServicePointIdleTime = 10;\r
googleUri = new Uri ("http://www.google.com");\r
yahooUri = new Uri ("http://www.yahoo.com");\r
apacheUri = new Uri ("http://www.apache.org");\r
}\r
\r
- [Test]\r
+ [TearDown]\r
+ public void Finish ()\r
+ {\r
+ ServicePointManager.MaxServicePointIdleTime = maxIdle;\r
+ }\r
+\r
+ [Test, ExpectedException (typeof (InvalidOperationException))]\r
+ [Category ("InetAccess")]\r
+#if TARGET_JVM\r
+ [Ignore ("Unsupported property - ServicePointManager.MaxServicePoints")]\r
+#endif\r
public void MaxServicePointManagers ()\r
{\r
- try {\r
- Assertion.AssertEquals ("#1", 0, ServicePointManager.MaxServicePoints);\r
- \r
- DoWebRequest (googleUri);\r
- Thread.Sleep (100);\r
- DoWebRequest (yahooUri);\r
- Thread.Sleep (100);\r
- DoWebRequest (apacheUri);\r
- Thread.Sleep (100);\r
- \r
- ServicePoint sp = ServicePointManager.FindServicePoint (googleUri);\r
- WriteServicePoint (sp);\r
- sp = ServicePointManager.FindServicePoint (yahooUri);\r
- WriteServicePoint (sp);\r
- sp = ServicePointManager.FindServicePoint (apacheUri);\r
- WriteServicePoint (sp);\r
- \r
- ServicePointManager.MaxServicePoints = 1;\r
+ Assert.AreEqual (0, ServicePointManager.MaxServicePoints, "#1");\r
+ \r
+ DoWebRequest (googleUri);\r
+ Thread.Sleep (100);\r
+ DoWebRequest (yahooUri);\r
+ Thread.Sleep (100);\r
+ DoWebRequest (apacheUri);\r
+ Thread.Sleep (100);\r
+ \r
+ ServicePoint sp = ServicePointManager.FindServicePoint (googleUri);\r
+ //WriteServicePoint (sp);\r
+ sp = ServicePointManager.FindServicePoint (yahooUri);\r
+ //WriteServicePoint (sp);\r
+ sp = ServicePointManager.FindServicePoint (apacheUri);\r
+ //WriteServicePoint (sp);\r
+ \r
+ ServicePointManager.MaxServicePoints = 1;\r
\r
- sp = ServicePointManager.FindServicePoint (googleUri);\r
- WriteServicePoint (sp);\r
- sp = ServicePointManager.FindServicePoint (yahooUri);\r
- WriteServicePoint (sp);\r
- sp = ServicePointManager.FindServicePoint (apacheUri);\r
- WriteServicePoint (sp);\r
- \r
- GC.Collect ();\r
- \r
- // hmm... aparently ms.net still has the service points even\r
- // though I set it to a max of 1.\r
- \r
- // this should force an exception then... \r
- sp = ServicePointManager.FindServicePoint (new Uri ("http://www.microsoft.com"));\r
- WriteServicePoint (sp);\r
- \r
- } catch (Exception e) {\r
- Assertion.Fail("The following unexpected Exception was thrown : " + e);\r
- }\r
+ sp = ServicePointManager.FindServicePoint (googleUri);\r
+ //WriteServicePoint (sp);\r
+ sp = ServicePointManager.FindServicePoint (yahooUri);\r
+ //WriteServicePoint (sp);\r
+ sp = ServicePointManager.FindServicePoint (apacheUri);\r
+ //WriteServicePoint (sp);\r
+ \r
+ GC.Collect ();\r
+ \r
+ // hmm... aparently ms.net still has the service points even\r
+ // though I set it to a max of 1.\r
+ \r
+ // this should force an exception then... \r
+ sp = ServicePointManager.FindServicePoint (new Uri ("http://www.microsoft.com"));\r
+ //WriteServicePoint (sp);\r
}\r
\r
[Test]\r
public void FindServicePoint ()\r
{\r
+ ServicePointManager.MaxServicePoints = 0;\r
ServicePoint sp = ServicePointManager.FindServicePoint (googleUri, new WebProxy (apacheUri));\r
- Assertion.AssertEquals ("#1", apacheUri, sp.Address);\r
- Assertion.AssertEquals ("#2", 2, sp.ConnectionLimit);\r
- Assertion.AssertEquals ("#3", "http", sp.ConnectionName);\r
+ Assert.AreEqual (apacheUri, sp.Address, "#1");\r
+ Assert.AreEqual (2, sp.ConnectionLimit, "#2");\r
+ Assert.AreEqual ("http", sp.ConnectionName, "#3");\r
}\r
\r
private void DoWebRequest (Uri uri)\r
{\r
WebRequest.Create (uri).GetResponse ().Close ();\r
}\r
- \r
+\r
+/* Unused code for now, but might be useful later for debugging\r
private void WriteServicePoint (ServicePoint sp)\r
{\r
Console.WriteLine ("\nAddress: " + sp.Address);\r
Console.WriteLine ("ProtocolVersion: " + sp.ProtocolVersion);\r
Console.WriteLine ("SupportsPipelining: " + sp.SupportsPipelining); \r
}\r
-}\r
+*/\r
\r
}\r
+}\r
\r