Imported Upstream version 4.2.0.179

Former-commit-id: 0a113cb3a6feb7873f632839b1307cc6033cd595
This commit is contained in:
Xamarin Public Jenkins
2015-08-26 07:17:56 -04:00
committed by Jo Shields
parent 183bba2c9a
commit 6992685b86
7507 changed files with 90259 additions and 657307 deletions

View File

@@ -2,7 +2,7 @@
// Microsoft.VisualBasic.* Test Cases
//
// Authors:
// Gert Driesen (drieseng@users.sourceforge.net)
// Gert Driesen (drieseng@users.sourceforge.net)
//
// (c) 2005 Novell
//
@@ -154,6 +154,40 @@ namespace MonoTests.Microsoft.VisualBasic
+ "Namespace{0}", NewLine), Generate ());
}
[Test]
public void AttributeAndImportsTest ()
{
CodeNamespace ns = new CodeNamespace ();
codeUnit.Namespaces.Add (ns);
ns.Imports.Add(new CodeNamespaceImport("System"));
ns.Imports.Add(new CodeNamespaceImport("System.Reflection"));
CodeAttributeDeclaration attrDec = new CodeAttributeDeclaration ();
attrDec.Name = "A";
codeUnit.AssemblyCustomAttributes.Add (attrDec);
Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
"Imports System{0}Imports System.Reflection{0}<Assembly: A()> {0}{0}",
NewLine), Generate ());
}
[Test]
public void AttributeAndImportsAndNamespaceTest ()
{
CodeNamespace ns = new CodeNamespace ("A");
codeUnit.Namespaces.Add (ns);
ns.Imports.Add(new CodeNamespaceImport("System"));
ns.Imports.Add(new CodeNamespaceImport("System.Reflection"));
CodeAttributeDeclaration attrDec = new CodeAttributeDeclaration ();
attrDec.Name = "A";
codeUnit.AssemblyCustomAttributes.Add (attrDec);
Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
"Imports System{0}Imports System.Reflection{0}<Assembly: A()> {0}{0}"
+ "Namespace A{0}End Namespace{0}", NewLine), Generate ());
}
[Test]
public void CodeSnippetTest ()
{

View File

@@ -39,6 +39,7 @@ namespace MonoTests.System.CodeDom.Compiler
[TestFixture]
public class CodeGeneratorGenerateFromCompileUnitTest {
[Test]
[Ignore ("This test is wrong; on .NET, ATTRIBUTE is not written and this attributePosition is always < 0.")]
public void When_Having_AssemblyAttribute_And_Using_Namespace_It_Should_Generate_Namespace_First_And_Attribute_Afterwards () {
ICodeGenerator generator = new SampleCodeGenerator ();
var compileUnit = ACompileUnitWithAttributeAndNamespace ();

View File

@@ -26,7 +26,7 @@ namespace MonoTests.System.ComponentModel
SynchronizationContext sc1 = new SynchronizationContext ();
SynchronizationContext sc2 = new SynchronizationContext ();
#if MOBILE
#if MOBILE && !MONODROID
Assert.IsNotNull (SynchronizationContext.Current, "A1");
#else
Assert.IsNull (SynchronizationContext.Current, "A1");

View File

@@ -0,0 +1,68 @@
//
// Authors:
// Alan McGovern <amcgovern@novell.com>
//
// Copyright (C) 2009 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using CM = System.ComponentModel;
using NUnit.Framework;
namespace MonoTests.System.ComponentModel {
[TestFixture]
public class CategoryAttributeTest {
[Test]
public void CategoryNamesTest()
{
Assert.AreEqual(CM.CategoryAttribute.Action.Category, "Action", "#1");
Assert.AreEqual(CM.CategoryAttribute.Appearance.Category, "Appearance", "#2");
Assert.AreEqual(CM.CategoryAttribute.Asynchronous.Category, "Asynchronous", "#3");
Assert.AreEqual(CM.CategoryAttribute.Behavior.Category, "Behavior", "#4");
Assert.AreEqual(CM.CategoryAttribute.Data.Category, "Data", "#5");
Assert.AreEqual(CM.CategoryAttribute.Design.Category, "Design", "#6");
Assert.AreEqual(CM.CategoryAttribute.Focus.Category, "Focus", "#7");
Assert.AreEqual(CM.CategoryAttribute.Format.Category, "Format", "#8");
Assert.AreEqual(CM.CategoryAttribute.Key.Category, "Key", "#9");
Assert.AreEqual(CM.CategoryAttribute.Layout.Category, "Layout", "#10");
Assert.AreEqual(CM.CategoryAttribute.Mouse.Category, "Mouse", "#11");
#if NET_2_1
Assert.AreEqual(CM.CategoryAttribute.Default.Category, "Default", "#12");
Assert.AreEqual(CM.CategoryAttribute.DragDrop.Category, "DragDrop", "#13");
Assert.AreEqual(CM.CategoryAttribute.WindowStyle.Category, "WindowStyle", "#14");
#else
Assert.AreEqual(CM.CategoryAttribute.Default.Category, "Misc", "#12");
Assert.AreEqual(CM.CategoryAttribute.DragDrop.Category, "Drag Drop", "#13");
Assert.AreEqual(CM.CategoryAttribute.WindowStyle.Category, "Window Style", "#14");
#endif
}
[Test]
public void CustomCategory ()
{
var ca = new CM.CategoryAttribute ("Foo Category");
Assert.AreEqual ("Foo Category", ca.Category);
}
}
}

View File

@@ -56,7 +56,7 @@ namespace MonoTests.System.ComponentModel {
Assert.IsFalse (dvat.Equals (true), "Equals(true)");
Assert.IsTrue (dvat.Equals (new DefaultValueAttribute (true)), "Equals(new)");
Assert.AreNotEqual (1, dvat.GetHashCode (), "GetHashCode");
Assert.AreEqual (1, dvat.GetHashCode (), "GetHashCode");
}
}
}

View File

@@ -168,12 +168,12 @@ namespace MonoTests.System.Configuration {
IEnumerator props = settings.Properties.GetEnumerator();
Assert.IsNotNull (props, "A1");
Assert.IsTrue (props.MoveNext(), "A2");
Assert.AreEqual ("Username", ((SettingsProperty)props.Current).Name, "A3");
Assert.IsTrue (props.MoveNext(), "A4");
Assert.AreEqual ("Address", ((SettingsProperty)props.Current).Name, "A5");
Assert.IsTrue (props.MoveNext(), "A2");
Assert.AreEqual ("Username", ((SettingsProperty)props.Current).Name, "A3");
Assert.AreEqual ("root", settings.Username, "A6");
Assert.AreEqual ("8 Cambridge Center", settings.Address, "A7");

View File

@@ -52,6 +52,16 @@ namespace MonoTests.System.Diagnostics
}
}
[Test] // Covers #26363
[NUnit.Framework.Category ("MobileNotWorking")]
public void GetProcesses_StartTime ()
{
foreach (var p in Process.GetProcesses ()) {
if (!p.HasExited && p.StartTime.Year < 1800)
Assert.Fail ("Process should not be started since the 18th century.");
}
}
[Test]
public void PriorityClass_NotStarted ()
{
@@ -768,12 +778,80 @@ namespace MonoTests.System.Diagnostics
Assert.AreEqual (true, r, "Null Argument Events Raised");
}
private ProcessStartInfo GetCrossPlatformStartInfo ()
[Test]
[NUnit.Framework.Category ("MobileNotWorking")]
public void TestEnableEventsAfterExitedEvent ()
{
return RunningOnUnix ? new ProcessStartInfo ("/bin/ls", "/") : new ProcessStartInfo ("help", "");
Process p = new Process ();
p.StartInfo = GetCrossPlatformStartInfo ();
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.RedirectStandardError = true;
var exitedCalledCounter = 0;
p.Exited += (object sender, EventArgs e) => {
exitedCalledCounter++;
Assert.IsTrue (p.HasExited);
};
p.EnableRaisingEvents = true;
p.Start ();
p.BeginErrorReadLine ();
p.BeginOutputReadLine ();
p.WaitForExit ();
Assert.AreEqual (1, exitedCalledCounter);
Thread.Sleep (50);
Assert.AreEqual (1, exitedCalledCounter);
}
[Test]
[NUnit.Framework.Category ("MobileNotWorking")]
public void TestEnableEventsBeforeExitedEvent ()
{
Process p = new Process ();
p.StartInfo = GetCrossPlatformStartInfo ();
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.RedirectStandardError = true;
p.EnableRaisingEvents = true;
var exitedCalledCounter = 0;
p.Exited += (object sender, EventArgs e) => {
exitedCalledCounter++;
Assert.IsTrue (p.HasExited);
};
p.Start ();
p.BeginErrorReadLine ();
p.BeginOutputReadLine ();
p.WaitForExit ();
Assert.AreEqual (1, exitedCalledCounter);
Thread.Sleep (50);
Assert.AreEqual (1, exitedCalledCounter);
}
ProcessStartInfo GetCrossPlatformStartInfo ()
{
if (RunningOnUnix) {
string path;
#if MONODROID
path = "/system/bin/ls";
#else
path = "/bin/ls";
#endif
return new ProcessStartInfo (path, "/");
} else
return new ProcessStartInfo ("help", "");
}
[Test]
public void ProcessName_NotStarted ()
{
@@ -842,6 +920,7 @@ namespace MonoTests.System.Diagnostics
}
[Test]
[NUnit.Framework.Category ("MobileNotWorking")]
public void DisposeWithDisposedStreams ()
{
var psi = GetCrossPlatformStartInfo ();
@@ -854,5 +933,40 @@ namespace MonoTests.System.Diagnostics
p.StandardOutput.BaseStream.Dispose ();
p.Dispose ();
}
[Test]
public void Modules () {
var modules = Process.GetCurrentProcess ().Modules;
foreach (var a in AppDomain.CurrentDomain.GetAssemblies ()) {
var found = false;
var name = a.GetName ();
StringBuilder sb = new StringBuilder ();
sb.AppendFormat ("Could not found: {0} {1}\n", name.Name, name.Version);
sb.AppendLine ("Looked in assemblies:");
foreach (var o in modules) {
var m = (ProcessModule) o;
sb.AppendFormat (" {0} {1}.{2}.{3}\n", m.FileName.ToString (),
m.FileVersionInfo.FileMajorPart,
m.FileVersionInfo.FileMinorPart,
m.FileVersionInfo.FileBuildPart);
if (!m.FileName.StartsWith ("[In Memory] " + name.Name))
continue;
var fv = m.FileVersionInfo;
if (fv.FileBuildPart != name.Version.Build ||
fv.FileMinorPart != name.Version.Minor ||
fv.FileMajorPart != name.Version.Major)
continue;
found = true;
}
Assert.IsTrue (found, sb.ToString ());
}
}
}
}

View File

@@ -99,7 +99,7 @@ namespace MonoTests.System.IO.Compression
MemoryStream backing = new MemoryStream (data);
DeflateStream compressing = new DeflateStream (backing, CompressionMode.Decompress);
compressing.Read (dummy, 0, 1);
}
}
[Test]
[ExpectedException (typeof (ArgumentNullException))]
@@ -376,6 +376,7 @@ namespace MonoTests.System.IO.Compression
}
[Test]
[Category ("AndroidNotWorking")] // system zlib returns Z_STREAM_ERROR
public void Bug28777_EmptyFlush ()
{
MemoryStream backing = new MemoryStream ();
@@ -386,6 +387,7 @@ namespace MonoTests.System.IO.Compression
}
[Test]
[Category ("AndroidNotWorking")] // system zlib returns Z_BUF_ERROR
public void Bug28777_DoubleFlush ()
{
byte[] buffer = new byte [4096];

View File

@@ -7,6 +7,8 @@
using NUnit.Framework;
using System;
using System.Globalization;
using System.IO;
using System.Net;
using System.Net.NetworkInformation;
@@ -29,18 +31,82 @@ namespace MonoTests.System.Net.NetworkInformation
}
Assert.IsTrue (numUnicastAddresses > 0);
}
// Borrowed from IPInterfaceProperties.cs
bool HasOnlyDefaultGateway (string iface)
{
int gwCount = 0;
int defaultGwCount = 0;
#if MONODROID
if (!File.Exists ("/proc/net/route"))
return false;
try {
using (StreamReader reader = new StreamReader ("/proc/net/route")) {
string line;
reader.ReadLine (); // Ignore first line
while ((line = reader.ReadLine ()) != null) {
line = line.Trim ();
if (line.Length == 0)
continue;
string [] parts = line.Split ('\t');
if (parts.Length < 3)
continue;
string gw_address = parts [2].Trim ();
byte [] ipbytes = new byte [4];
if (gw_address.Length == 8 && iface.Equals (parts [0], StringComparison.OrdinalIgnoreCase)) {
for (int i = 0; i < 4; i++) {
if (!Byte.TryParse (gw_address.Substring (i * 2, 2), NumberStyles.HexNumber, null, out ipbytes [3 - i]))
continue;
}
IPAddress ip = new IPAddress (ipbytes);
if (ip.Equals (IPAddress.Any))
defaultGwCount++;
else
gwCount++;
}
}
}
} catch {
}
#endif
return gwCount == 0 && defaultGwCount > 0;
}
[Test]
public void AtLeastOneGatewayAddress ()
{
int numGatewayAddresses = 0;
NetworkInterface[] adapters = NetworkInterface.GetAllNetworkInterfaces ();
// On Android (possibly on other systems too) it is possible that no gateway address is available and its lack is NOT an error
// Here is a sample of /proc/net/route from Nexus 9 running Android 5.1.1 (IPInterfaceProperties parses that file on Linux)
//
// Iface Destination Gateway Flags RefCnt Use Metric Mask MTU Window IRTT
// wlan0 0001A8C0 00000000 0001 0 0 0 00FFFFFF 0 0 0
//
// Gateway is set to any address and it is explicitly ignored by the route information parser
//
// For comparison, here's route contents from an Android 4.4.4 device:
//
// Iface Destination Gateway Flags RefCnt Use Metric Mask MTU Window IRTT
// wlan0 00000000 0101A8C0 0003 0 0 0 00000000 0 0 0
// wlan0 00000000 0101A8C0 0003 0 0 203 00000000 0 0 0
// wlan0 0001A8C0 00000000 0001 0 0 0 00FFFFFF 0 0 0
// wlan0 0001A8C0 00000000 0001 0 0 0 00FFFFFF 0 0 0
// wlan0 0001A8C0 00000000 0001 0 0 203 00FFFFFF 0 0 0
// wlan0 0101A8C0 00000000 0005 0 0 0 FFFFFFFF 0 0 0
//
// Obviously, this test fails on the first device and succeeds on the second. For this reason the test is modified to succeed
// in case of devices like the first one since it's not a real failure but a shortcoming of the .NET API
//
foreach (NetworkInterface adapter in adapters)
{
IPInterfaceProperties adapterProperties = adapter.GetIPProperties ();
GatewayIPAddressInformationCollection gatewayAddresses = adapterProperties.GatewayAddresses;
numGatewayAddresses += gatewayAddresses.Count;
numGatewayAddresses += HasOnlyDefaultGateway (adapter.Name) ? 1 : gatewayAddresses.Count;
}
Assert.IsTrue (numGatewayAddresses > 0);
}
@@ -56,6 +122,9 @@ namespace MonoTests.System.Net.NetworkInformation
}
[Test]
// The code works as expected when part of a regular app. It fails when executed from within an NUnit test
// Might be a problem with the test suite. To investigate.
[Category("AndroidNotWorking")]
public void AtLeastOneDnsAddress ()
{
int numDnsAddresses = 0;
@@ -66,6 +135,7 @@ namespace MonoTests.System.Net.NetworkInformation
IPAddressCollection dnsAddresses = adapterProperties.DnsAddresses;
numDnsAddresses += dnsAddresses.Count;
}
Console.WriteLine ("numDnsAddresses == {0}", numDnsAddresses);
// reading /etc/resolve.conf does not work on iOS devices (but works on simulator)
// ref: https://bugzilla.xamarin.com/show_bug.cgi?id=27707
#if !MONOTOUCH

View File

@@ -74,9 +74,9 @@ public class SslStreamTest {
state.ServerIOException = !server;
try {
Thread serverThread = new Thread (() => StartServerAndAuthenticate (state));
serverThread.Start (null);
serverThread.Start ();
Thread clientThread = new Thread (() => StartClientAndAuthenticate (state, endPoint));
clientThread.Start (null);
clientThread.Start ();
Assert.AreEqual (server, state.ServerAuthenticated.WaitOne (TimeSpan.FromSeconds (2)),
"server not authenticated");
Assert.AreEqual (client, state.ClientAuthenticated.WaitOne (TimeSpan.FromSeconds (2)),

View File

@@ -1 +1 @@
697830b3fd848d3d5f96b48aab738910621cfffe
f8c2f4cb750d69cbda8d81e1312338786dae656f

View File

@@ -10,6 +10,7 @@ using System.Text;
using NUnit.Framework;
using MonoTests.Helpers;
namespace MonoTests.System.Net.WebSockets
{
@@ -17,7 +18,7 @@ namespace MonoTests.System.Net.WebSockets
public class ClientWebSocketTest
{
const string EchoServerUrl = "ws://echo.websocket.org";
const int Port = 42123;
int Port = NetworkHelpers.FindFreePort ();
HttpListener listener;
ClientWebSocket socket;
MethodInfo headerSetMethod;
@@ -47,6 +48,7 @@ namespace MonoTests.System.Net.WebSockets
}
[Test]
[Category ("AndroidNotWorking")] // Fails when ran as part of the entire BCL test suite. Works when only this fixture is ran
public void ServerHandshakeReturnCrapStatusCodeTest ()
{
// On purpose,
@@ -63,6 +65,7 @@ namespace MonoTests.System.Net.WebSockets
}
[Test]
[Category ("AndroidNotWorking")] // Fails when ran as part of the entire BCL test suite. Works when only this fixture is ran
public void ServerHandshakeReturnWrongUpgradeHeader ()
{
#pragma warning disable 4014
@@ -81,6 +84,7 @@ namespace MonoTests.System.Net.WebSockets
}
[Test]
[Category ("AndroidNotWorking")] // Fails when ran as part of the entire BCL test suite. Works when only this fixture is ran
public void ServerHandshakeReturnWrongConnectionHeader ()
{
#pragma warning disable 4014
@@ -101,6 +105,7 @@ namespace MonoTests.System.Net.WebSockets
}
[Test]
[Category ("AndroidNotWorking")] // The test hangs when ran as part of the entire BCL test suite. Works when only this fixture is ran
public void EchoTest ()
{
const string Payload = "This is a websocket test";
@@ -125,6 +130,7 @@ namespace MonoTests.System.Net.WebSockets
}
[Test]
[Category ("AndroidNotWorking")] // Fails when ran as part of the entire BCL test suite. Works when only this fixture is ran
public void CloseOutputAsyncTest ()
{
Assert.IsTrue (socket.ConnectAsync (new Uri (EchoServerUrl), CancellationToken.None).Wait (5000));
@@ -141,6 +147,7 @@ namespace MonoTests.System.Net.WebSockets
}
[Test]
[Category ("AndroidNotWorking")] // Fails when ran as part of the entire BCL test suite. Works when only this fixture is ran
public void CloseAsyncTest ()
{
Assert.IsTrue (socket.ConnectAsync (new Uri (EchoServerUrl), CancellationToken.None).Wait (5000));
@@ -157,6 +164,7 @@ namespace MonoTests.System.Net.WebSockets
}
[Test, ExpectedException (typeof (ArgumentNullException))]
[Category ("AndroidNotWorking")] // Fails when ran as part of the entire BCL test suite. Works when only this fixture is ran
public void SendAsyncArgTest_NoArray ()
{
Assert.IsTrue (socket.ConnectAsync (new Uri (EchoServerUrl), CancellationToken.None).Wait (5000));
@@ -170,6 +178,7 @@ namespace MonoTests.System.Net.WebSockets
}
[Test, ExpectedException (typeof (ArgumentNullException))]
[Category ("AndroidNotWorking")] // Fails when ran as part of the entire BCL test suite. Works when only this fixture is ran
public void ReceiveAsyncArgTest_NoArray ()
{
Assert.IsTrue (socket.ConnectAsync (new Uri (EchoServerUrl), CancellationToken.None).Wait (5000));
@@ -177,6 +186,7 @@ namespace MonoTests.System.Net.WebSockets
}
[Test]
[Category ("AndroidNotWorking")] // Fails when ran as part of the entire BCL test suite. Works when only this fixture is ran
public void ReceiveAsyncWrongState_Closed ()
{
try {
@@ -191,6 +201,7 @@ namespace MonoTests.System.Net.WebSockets
}
[Test]
[Category ("AndroidNotWorking")] // Fails when ran as part of the entire BCL test suite. Works when only this fixture is ran
public void SendAsyncWrongState_Closed ()
{
try {
@@ -205,6 +216,7 @@ namespace MonoTests.System.Net.WebSockets
}
[Test]
[Category ("AndroidNotWorking")] // Fails when ran as part of the entire BCL test suite. Works when only this fixture is ran
public void SendAsyncWrongState_CloseSent ()
{
try {

View File

@@ -184,5 +184,31 @@ namespace MonoTests.System.Net
Assert.AreEqual ("/RequestUriDecodeTest/?a=b&c=d%26e", request.Url.PathAndQuery);
listener.Close ();
}
[Test] // #29927
public void HttpRequestUriUnescape ()
{
var prefix = "http://localhost:12345/";
var key = "Product/1";
var expectedUrl = prefix + key + "/";
var rawUrl = prefix + Uri.EscapeDataString (key) + "/";
HttpListener listener = new HttpListener ();
listener.Prefixes.Add (prefix);
listener.Start ();
var contextTask = listener.GetContextAsync ();
var request = (HttpWebRequest) WebRequest.Create (rawUrl);
request.GetResponseAsync ();
if(!contextTask.Wait (1000))
Assert.Fail ("Timeout");
Assert.AreEqual (expectedUrl, contextTask.Result.Request.Url.AbsoluteUri);
listener.Close ();
}
}
}

View File

@@ -31,6 +31,7 @@ using System.Net;
using System.Net.Sockets;
using System.Threading;
using NUnit.Framework;
using MonoTests.Helpers;
namespace MonoTests.System.Net {
[TestFixture]
@@ -40,7 +41,7 @@ namespace MonoTests.System.Net {
[SetUp]
public void SetUp () {
port = new Random ().Next (7777, 8000);
port = NetworkHelpers.FindFreePort ();
}
[Test]
@@ -475,9 +476,10 @@ namespace MonoTests.System.Net {
}
[Test]
[Category ("AndroidNotWorking")] // Fails ("reuse1") when ran as part of the entire BCL test suite. Works when only this fixture is ran
public void ConnectionReuse ()
{
var uri = "http://localhost:1338/";
var uri = "http://localhost:" + NetworkHelpers.FindFreePort () + "/";
HttpListener listener = new HttpListener ();
listener.Prefixes.Add (uri);

View File

@@ -1 +1 @@
326ff298024580ff7205d0cafe3cd61ce9165310
3a7ce31d0c602f28af3549eefc482fcb33d7e65a

View File

@@ -14,6 +14,8 @@ using System.Net;
using System.Net.Sockets;
using System.Text;
using MonoTests.Helpers;
using NUnit.Framework;
namespace MonoTests.System.Net
@@ -24,7 +26,7 @@ namespace MonoTests.System.Net
[Test]
public void CharacterSet_Disposed ()
{
IPEndPoint ep = new IPEndPoint (IPAddress.Loopback, 8000);
IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
string url = "http://" + ep.ToString () + "/test/";
using (SocketResponder responder = new SocketResponder (ep, new SocketRequestHandler (FullResponseHandler))) {
@@ -54,7 +56,7 @@ namespace MonoTests.System.Net
[Test]
public void Close_Disposed ()
{
IPEndPoint ep = new IPEndPoint (IPAddress.Loopback, 8000);
IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
string url = "http://" + ep.ToString () + "/test/";
using (SocketResponder responder = new SocketResponder (ep, new SocketRequestHandler (FullResponseHandler))) {
@@ -75,7 +77,7 @@ namespace MonoTests.System.Net
[Test]
public void ContentEncoding_Disposed ()
{
IPEndPoint ep = new IPEndPoint (IPAddress.Loopback, 8000);
IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
string url = "http://" + ep.ToString () + "/test/";
using (SocketResponder responder = new SocketResponder (ep, new SocketRequestHandler (FullResponseHandler))) {
@@ -105,7 +107,7 @@ namespace MonoTests.System.Net
[Test]
public void ContentLength_Disposed ()
{
IPEndPoint ep = new IPEndPoint (IPAddress.Loopback, 8000);
IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
string url = "http://" + ep.ToString () + "/test/";
using (SocketResponder responder = new SocketResponder (ep, new SocketRequestHandler (FullResponseHandler))) {
@@ -127,7 +129,7 @@ namespace MonoTests.System.Net
[Test]
public void ContentType_Disposed ()
{
IPEndPoint ep = new IPEndPoint (IPAddress.Loopback, 8000);
IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
string url = "http://" + ep.ToString () + "/test/";
using (SocketResponder responder = new SocketResponder (ep, new SocketRequestHandler (FullResponseHandler))) {
@@ -157,7 +159,7 @@ namespace MonoTests.System.Net
[Test]
public void Cookies_Disposed ()
{
IPEndPoint ep = new IPEndPoint (IPAddress.Loopback, 8000);
IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
string url = "http://" + ep.ToString () + "/test/";
using (SocketResponder responder = new SocketResponder (ep, new SocketRequestHandler (FullResponseHandler))) {
@@ -197,7 +199,7 @@ namespace MonoTests.System.Net
[Test]
public void GetResponseHeader_Disposed ()
{
IPEndPoint ep = new IPEndPoint (IPAddress.Loopback, 8000);
IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
string url = "http://" + ep.ToString () + "/test/";
using (SocketResponder responder = new SocketResponder (ep, new SocketRequestHandler (FullResponseHandler))) {
@@ -227,7 +229,7 @@ namespace MonoTests.System.Net
[Test]
public void GetResponseStream_Disposed ()
{
IPEndPoint ep = new IPEndPoint (IPAddress.Loopback, 8000);
IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
string url = "http://" + ep.ToString () + "/test/";
using (SocketResponder responder = new SocketResponder (ep, new SocketRequestHandler (FullResponseHandler))) {
@@ -257,7 +259,7 @@ namespace MonoTests.System.Net
[Test]
public void Headers_Disposed ()
{
IPEndPoint ep = new IPEndPoint (IPAddress.Loopback, 8000);
IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
string url = "http://" + ep.ToString () + "/test/";
using (SocketResponder responder = new SocketResponder (ep, new SocketRequestHandler (FullResponseHandler))) {
@@ -286,7 +288,7 @@ namespace MonoTests.System.Net
[Test]
public void LastModified_Disposed ()
{
IPEndPoint ep = new IPEndPoint (IPAddress.Loopback, 8000);
IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
string url = "http://" + ep.ToString () + "/test/";
using (SocketResponder responder = new SocketResponder (ep, new SocketRequestHandler (FullResponseHandler))) {
@@ -316,7 +318,7 @@ namespace MonoTests.System.Net
[Test]
public void Method_Disposed ()
{
IPEndPoint ep = new IPEndPoint (IPAddress.Loopback, 8000);
IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
string url = "http://" + ep.ToString () + "/test/";
using (SocketResponder responder = new SocketResponder (ep, new SocketRequestHandler (FullResponseHandler))) {
@@ -346,7 +348,7 @@ namespace MonoTests.System.Net
[Test]
public void ProtocolVersion_Disposed ()
{
IPEndPoint ep = new IPEndPoint (IPAddress.Loopback, 8000);
IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
string url = "http://" + ep.ToString () + "/test/";
using (SocketResponder responder = new SocketResponder (ep, new SocketRequestHandler (FullResponseHandler))) {
@@ -376,7 +378,7 @@ namespace MonoTests.System.Net
[Test]
public void ResponseUri_Disposed ()
{
IPEndPoint ep = new IPEndPoint (IPAddress.Loopback, 8000);
IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
string url = "http://" + ep.ToString () + "/test/";
using (SocketResponder responder = new SocketResponder (ep, new SocketRequestHandler (FullResponseHandler))) {
@@ -406,7 +408,7 @@ namespace MonoTests.System.Net
[Test]
public void Server_Disposed ()
{
IPEndPoint ep = new IPEndPoint (IPAddress.Loopback, 8000);
IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
string url = "http://" + ep.ToString () + "/test/";
using (SocketResponder responder = new SocketResponder (ep, new SocketRequestHandler (FullResponseHandler))) {
@@ -436,7 +438,7 @@ namespace MonoTests.System.Net
[Test]
public void StatusCode_Disposed ()
{
IPEndPoint ep = new IPEndPoint (IPAddress.Loopback, 8000);
IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
string url = "http://" + ep.ToString () + "/test/";
using (SocketResponder responder = new SocketResponder (ep, new SocketRequestHandler (FullResponseHandler))) {
@@ -458,7 +460,7 @@ namespace MonoTests.System.Net
[Test]
public void StatusDescription_Disposed ()
{
IPEndPoint ep = new IPEndPoint (IPAddress.Loopback, 8000);
IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
string url = "http://" + ep.ToString () + "/test/";
using (SocketResponder responder = new SocketResponder (ep, new SocketRequestHandler (FullResponseHandler))) {
@@ -511,7 +513,7 @@ namespace MonoTests.System.Net
[Test]
public void BeginRead_Buffer_Null ()
{
IPEndPoint ep = new IPEndPoint (IPAddress.Loopback, 8000);
IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
string url = "http://" + ep.ToString () + "/test/";
using (SocketResponder responder = new SocketResponder (ep, new SocketRequestHandler (HttpWebResponseTest.FullResponseHandler))) {
@@ -562,7 +564,7 @@ namespace MonoTests.System.Net
[Test]
public void BeginWrite ()
{
IPEndPoint ep = new IPEndPoint (IPAddress.Loopback, 8000);
IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
string url = "http://" + ep.ToString () + "/test/";
using (SocketResponder responder = new SocketResponder (ep, new SocketRequestHandler (HttpWebResponseTest.FullResponseHandler))) {
@@ -597,7 +599,7 @@ namespace MonoTests.System.Net
[Category ("NotWorking")]
public void CanRead ()
{
IPEndPoint ep = new IPEndPoint (IPAddress.Loopback, 8000);
IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
string url = "http://" + ep.ToString () + "/test/";
using (SocketResponder responder = new SocketResponder (ep, new SocketRequestHandler (HttpWebResponseTest.FullResponseHandler))) {
@@ -626,7 +628,7 @@ namespace MonoTests.System.Net
[Test]
public void CanSeek ()
{
IPEndPoint ep = new IPEndPoint (IPAddress.Loopback, 8000);
IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
string url = "http://" + ep.ToString () + "/test/";
using (SocketResponder responder = new SocketResponder (ep, new SocketRequestHandler (HttpWebResponseTest.FullResponseHandler))) {
@@ -655,7 +657,7 @@ namespace MonoTests.System.Net
[Test] // bug #324182
public void CanTimeout ()
{
IPEndPoint ep = new IPEndPoint (IPAddress.Loopback, 8000);
IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
string url = "http://" + ep.ToString () + "/test/";
using (SocketResponder responder = new SocketResponder (ep, new SocketRequestHandler (HttpWebResponseTest.FullResponseHandler))) {
@@ -684,7 +686,7 @@ namespace MonoTests.System.Net
[Test]
public void CanWrite ()
{
IPEndPoint ep = new IPEndPoint (IPAddress.Loopback, 8000);
IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
string url = "http://" + ep.ToString () + "/test/";
using (SocketResponder responder = new SocketResponder (ep, new SocketRequestHandler (HttpWebResponseTest.FullResponseHandler))) {
@@ -713,7 +715,7 @@ namespace MonoTests.System.Net
[Test]
public void Read ()
{
IPEndPoint ep = new IPEndPoint (IPAddress.Loopback, 8000);
IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
string url = "http://" + ep.ToString () + "/test/";
using (SocketResponder responder = new SocketResponder (ep, new SocketRequestHandler (HttpWebResponseTest.FullResponseHandler))) {
@@ -752,7 +754,7 @@ namespace MonoTests.System.Net
[Test]
public void Read_Buffer_Null ()
{
IPEndPoint ep = new IPEndPoint (IPAddress.Loopback, 8000);
IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
string url = "http://" + ep.ToString () + "/test/";
using (SocketResponder responder = new SocketResponder (ep, new SocketRequestHandler (HttpWebResponseTest.FullResponseHandler))) {
@@ -803,7 +805,7 @@ namespace MonoTests.System.Net
[Test]
public void Read_Count_Negative ()
{
IPEndPoint ep = new IPEndPoint (IPAddress.Loopback, 8000);
IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
string url = "http://" + ep.ToString () + "/test/";
using (SocketResponder responder = new SocketResponder (ep, new SocketRequestHandler (HttpWebResponseTest.FullResponseHandler))) {
@@ -855,7 +857,7 @@ namespace MonoTests.System.Net
[Test]
public void Read_Count_Overflow ()
{
IPEndPoint ep = new IPEndPoint (IPAddress.Loopback, 8000);
IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
string url = "http://" + ep.ToString () + "/test/";
using (SocketResponder responder = new SocketResponder (ep, new SocketRequestHandler (HttpWebResponseTest.FullResponseHandler))) {
@@ -907,7 +909,7 @@ namespace MonoTests.System.Net
[Test]
public void Read_Offset_Negative ()
{
IPEndPoint ep = new IPEndPoint (IPAddress.Loopback, 8000);
IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
string url = "http://" + ep.ToString () + "/test/";
using (SocketResponder responder = new SocketResponder (ep, new SocketRequestHandler (HttpWebResponseTest.FullResponseHandler))) {
@@ -959,7 +961,7 @@ namespace MonoTests.System.Net
[Test]
public void Read_Offset_Overflow ()
{
IPEndPoint ep = new IPEndPoint (IPAddress.Loopback, 8000);
IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
string url = "http://" + ep.ToString () + "/test/";
using (SocketResponder responder = new SocketResponder (ep, new SocketRequestHandler (HttpWebResponseTest.FullResponseHandler))) {
@@ -1012,7 +1014,7 @@ namespace MonoTests.System.Net
[Category ("NotWorking")]
public void Read_Stream_Closed ()
{
IPEndPoint ep = new IPEndPoint (IPAddress.Loopback, 8000);
IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
string url = "http://" + ep.ToString () + "/test/";
using (SocketResponder responder = new SocketResponder (ep, new SocketRequestHandler (HttpWebResponseTest.FullResponseHandler))) {
@@ -1077,7 +1079,7 @@ namespace MonoTests.System.Net
[Test]
public void ReadTimeout ()
{
IPEndPoint ep = new IPEndPoint (IPAddress.Loopback, 8000);
IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
string url = "http://" + ep.ToString () + "/test/";
using (SocketResponder responder = new SocketResponder (ep, new SocketRequestHandler (HttpWebResponseTest.FullResponseHandler))) {
@@ -1106,7 +1108,7 @@ namespace MonoTests.System.Net
[Test]
public void Write ()
{
IPEndPoint ep = new IPEndPoint (IPAddress.Loopback, 8000);
IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
string url = "http://" + ep.ToString () + "/test/";
using (SocketResponder responder = new SocketResponder (ep, new SocketRequestHandler (HttpWebResponseTest.FullResponseHandler))) {
@@ -1140,7 +1142,7 @@ namespace MonoTests.System.Net
[Test]
public void WriteTimeout ()
{
IPEndPoint ep = new IPEndPoint (IPAddress.Loopback, 8000);
IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
string url = "http://" + ep.ToString () + "/test/";
using (SocketResponder responder = new SocketResponder (ep, new SocketRequestHandler (HttpWebResponseTest.FullResponseHandler))) {

View File

@@ -87,7 +87,7 @@ public class ServicePointManagerTest
ServicePointManager.MaxServicePoints = 0;
ServicePoint sp = ServicePointManager.FindServicePoint (googleUri, new WebProxy (apacheUri));
Assert.AreEqual (apacheUri, sp.Address, "#1");
#if NET_2_1
#if NET_2_1 && !MONODROID
Assert.AreEqual (10, sp.ConnectionLimit, "#2");
#else
Assert.AreEqual (2, sp.ConnectionLimit, "#2");

View File

@@ -53,10 +53,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
//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
// in both instances property CurrentConnections is 0 according to ms.net.
// let's see what it says when we do async operations...
@@ -83,10 +86,11 @@ public class ServicePointTest
//Console.WriteLine ("ContentLength: " + res2.ContentLength);
res2.Close ();
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");
ServicePoint sp2 = ServicePointManager.FindServicePoint (uri2);
sp2 = ServicePointManager.FindServicePoint (uri2);
req2 = (HttpWebRequest) WebRequest.Create (uri2);
async = req2.BeginGetResponse (null, null);
//WriteServicePoint ("Large file: after async BeginGetResponse", sp2);
@@ -97,6 +101,7 @@ public class ServicePointTest
// and so it shows
//Console.WriteLine ("ContentLength: " + res2.ContentLength);
res2.Close ();
#endif
// what's the limit of the cache?
@@ -148,6 +153,7 @@ public class ServicePointTest
[Test]
[Category ("InetAccess")]
[Category ("AndroidNotWorking")] // #A1 fails
public void EndPointBind ()
{
Uri uri = new Uri ("http://www.go-mono.com/");
@@ -163,7 +169,7 @@ public class ServicePointTest
};
req.GetResponse ().Close ();
Assert.IsTrue (called);
Assert.IsTrue (called, "#A1");
req = (HttpWebRequest) WebRequest.Create (uri);
called = false;
@@ -174,7 +180,29 @@ public class ServicePointTest
};
req.GetResponse ().Close ();
Assert.IsTrue (called);
Assert.IsTrue (called, "#A2");
}
public static void GetRequestStreamCallback (IAsyncResult asynchronousResult)
{
}
[Test] //Covers #19823
public void CloseConnectionGroupConcurency ()
{
// Try with multiple service points
for (var i = 0; i < 10; i++) {
Uri targetUri = new Uri ("http://" + i + ".mono-project.com");
var req = (HttpWebRequest) HttpWebRequest.Create (targetUri);
req.ContentType = "application/x-www-form-urlencoded";
req.Method = "POST";
req.ConnectionGroupName = "" + i;
req.ServicePoint.MaxIdleTime = 1;
req.BeginGetRequestStream (new AsyncCallback (GetRequestStreamCallback), req);
Thread.Sleep (1);
req.ServicePoint.CloseConnectionGroup (req.ConnectionGroupName);
}
}
// Debug code not used now, but could be useful later

View File

@@ -119,6 +119,14 @@ namespace MonoTests.System.Net
// ignore interruption of blocking call
if (ex.ErrorCode != SOCKET_CLOSED && ex.ErrorCode != SOCKET_INVALID_ARGS)
throw;
#if MOBILE
} catch (InvalidOperationException ex) {
// This breaks some tests running on Android. The problem is that the stack trace
// doesn't point to where the exception is actually thrown from but the entire process
// is aborted because of unhandled exception.
Console.WriteLine ("SocketResponder.Listen failed:");
Console.WriteLine (ex);
#endif
} finally {
Thread.Sleep (500);
if (socket != null)

View File

@@ -16,6 +16,8 @@ using System.Text;
using System.Threading;
using NUnit.Framework;
using MonoTests.Helpers;
namespace MonoTests.System.Net
{
[TestFixture]
@@ -1415,10 +1417,11 @@ namespace MonoTests.System.Net
}
[Test]
[Category ("AndroidNotWorking")] // Fails when ran as part of the entire BCL test suite. Works when only this fixture is ran
public void UploadValues1 ()
{
IPEndPoint ep = new IPEndPoint (IPAddress.Loopback, 8000);
string url = "http://" + IPAddress.Loopback.ToString () + ":8000/test/";
IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint ();
string url = "http://" + ep.ToString () + "/test/";
using (SocketResponder responder = new SocketResponder (ep, new SocketRequestHandler (EchoRequestHandler))) {
responder.Start ();
@@ -1781,9 +1784,10 @@ namespace MonoTests.System.Net
#if NET_4_5
[Test]
[Category ("AndroidNotWorking")] // Fails when ran as part of the entire BCL test suite. Works when only this fixture is ran
public void UploadStringAsyncCancelEvent ()
{
UploadAsyncCancelEventTest ((webClient, uri, cancelEvent) =>
UploadAsyncCancelEventTest (9301, (webClient, uri, cancelEvent) =>
{
webClient.UploadStringCompleted += (sender, args) =>
@@ -1797,9 +1801,10 @@ namespace MonoTests.System.Net
}
[Test]
[Category ("AndroidNotWorking")] // Fails when ran as part of the entire BCL test suite. Works when only this fixture is ran
public void UploadDataAsyncCancelEvent ()
{
UploadAsyncCancelEventTest ((webClient, uri, cancelEvent) =>
UploadAsyncCancelEventTest (9302, (webClient, uri, cancelEvent) =>
{
webClient.UploadDataCompleted += (sender, args) =>
{
@@ -1812,9 +1817,10 @@ namespace MonoTests.System.Net
}
[Test]
[Category ("AndroidNotWorking")] // Fails when ran as part of the entire BCL test suite. Works when only this fixture is ran
public void UploadValuesAsyncCancelEvent ()
{
UploadAsyncCancelEventTest ((webClient, uri, cancelEvent) =>
UploadAsyncCancelEventTest (9303, (webClient, uri, cancelEvent) =>
{
webClient.UploadValuesCompleted += (sender, args) =>
{
@@ -1827,9 +1833,10 @@ namespace MonoTests.System.Net
}
[Test]
[Category ("AndroidNotWorking")] // Fails when ran as part of the entire BCL test suite. Works when only this fixture is ran
public void UploadFileAsyncCancelEvent ()
{
UploadAsyncCancelEventTest ((webClient, uri, cancelEvent) =>
UploadAsyncCancelEventTest (9304,(webClient, uri, cancelEvent) =>
{
string tempFile = Path.Combine (_tempFolder, "upload.tmp");
File.Create (tempFile).Close ();
@@ -1845,6 +1852,7 @@ namespace MonoTests.System.Net
}
[Test]
[Category ("AndroidNotWorking")] // Test suite hangs if the tests runs as part of the entire BCL suite. Works when only this fixture is ran
public void UploadFileAsyncContentType ()
{
var serverUri = "http://localhost:13370/";
@@ -1868,10 +1876,10 @@ namespace MonoTests.System.Net
#endif
#if NET_4_0
public void UploadAsyncCancelEventTest (Action<WebClient, Uri, EventWaitHandle> uploadAction)
public void UploadAsyncCancelEventTest (int port, Action<WebClient, Uri, EventWaitHandle> uploadAction)
{
var ep = new IPEndPoint (IPAddress.Loopback, 8000);
string url = "http://" + IPAddress.Loopback + ":8000/test/";
var ep = NetworkHelpers.LocalEphemeralEndPoint ();
string url = "http://" + ep.ToString() + "/test/";
using (var responder = new SocketResponder (ep, EchoRequestHandler))
{

Some files were not shown because too many files have changed in this diff Show More