Imported Upstream version 3.6.0

Former-commit-id: da6be194a6b1221998fc28233f2503bd61dd9d14
This commit is contained in:
Jo Shields
2014-08-13 10:39:27 +01:00
commit a575963da9
50588 changed files with 8155799 additions and 0 deletions

View File

@@ -0,0 +1,60 @@
2009-06-25 Zoltan Varga <vargaz@gmail.com>
* *.cs: Convert all tests to new-style nunit classes/methods.
2008-06-14 Zoltan Varga <vargaz@gmail.com>
* SynchronizationAttributeTest.cs: Reenable some tests which seem to
work now.
2005-02-21 Nick Drochak <ndrochak@ieee.org>
* SoapServicesTest.cs: OK, i don't know how to handle multi-registrations.
Just disable the whole test on Mono for now until an expert can help out.
2005-02-20 Nick Drochak <ndrochak@ieee.org>
* SoapServicesTest.cs: Make test work on cygwin again. Order in which
tests are run can make a difference.
2005-01-31 Nick Drochak <ndrochak@ieee.org>
* SoapServicesTest.cs: Pull out asserts that do not work on mono.
* SynchronizationAttributeTest.cs: Run test on mono, but not .NET.
2004-04-06 Lluis Sanchez Gual <lluis@ximian.com>
* SynchronizationAttributeTest.cs: Added test for Monitor.Exit.
2004-01-08 Lluis Sanchez Gual <lluis@ximian.com>
* SynchronizationAttributeTest.cs: Improved test.
2003-11-26 Lluis Sanchez Gual <lluis@ximian.com>
* SoapServicesTest.cs: New test added.
2003-11-19 Lluis Sanchez Gual <lluis@ximian.com>
* ContextTest.cs, SynchronizationAttributeTest.cs: New tests added.
2003-06-19 Nick Drochak <ndrochak@gol.com>
* RemotingServicesTest.cs: Lazy fix/workaround for "can't reuse
channel" errors. Tests now pass.
* RemotingConfigurationTest.cs: Don't rely on test order, and wrap some
.NET 1.1 stuff.
2003-06-18 Nick Drochak <ndrochak@gol.com>
* RemotingServicesTest.cs: Change to nunit v2 format.
2003-03-11 Jean-Marc Andre <jean-marc.andre@polymtl.ca>
* RemotingConfigurationTest.cs: New unit test added
2003-03-03 Jean-Marc Andre <jean-marc.andre@polymtl.ca>
* RemotingServicesTest.cs: New unit test added

View File

@@ -0,0 +1,112 @@
//
// MonoTests.System.Runtime.Remoting.BaseCalls.cs
//
// Author: Lluis Sanchez Gual (lluis@ximian.com)
//
// 2003 (C) Copyright, Novell, Inc.
//
using System;
using System.Threading;
using System.Collections;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Activation;
using System.Runtime.Remoting.Contexts;
using NUnit.Framework;
namespace MonoTests.System.Runtime.Remoting
{
public class NeedsContextAttribute: Attribute, IContextAttribute
{
public void GetPropertiesForNewContext (IConstructionCallMessage msg) {}
public bool IsContextOK (Context ctx, IConstructionCallMessage msg) { return false; }
}
[NeedsContextAttribute]
public class TestCbo: ContextBoundObject
{
public Context GetContext ()
{
return Thread.CurrentContext;
}
}
[TestFixture]
public class ContextTest
{
TestCbo cbo = new TestCbo ();
Context otherCtx;
LocalDataStoreSlot slot;
[Test]
public void TestDoCallback ()
{
otherCtx = cbo.GetContext ();
Assert.IsTrue (Thread.CurrentContext != otherCtx, "New context not created");
otherCtx.DoCallBack (new CrossContextDelegate (DelegateTarget));
}
void DelegateTarget ()
{
Assert.IsTrue (Thread.CurrentContext == otherCtx, "Wrong context");
}
[Test]
public void TestDatastore ()
{
otherCtx = cbo.GetContext ();
slot = Context.AllocateDataSlot ();
LocalDataStoreSlot namedSlot1 = Context.AllocateNamedDataSlot ("slot1");
LocalDataStoreSlot namedSlot2 = Context.GetNamedDataSlot ("slot2");
Context.SetData (slot, "data");
Context.SetData (namedSlot1, "data1");
Context.SetData (namedSlot2, "data2");
otherCtx.DoCallBack (new CrossContextDelegate (CheckOtherContextDatastore));
Assert.IsTrue (Context.GetData (slot).Equals ("data"), "Wrong data 1");
Assert.IsTrue (Context.GetData (namedSlot1).Equals ("data1"), "Wrong data 2");
Assert.IsTrue (Context.GetData (namedSlot2).Equals ("data2"), "Wrong data 3");
try
{
namedSlot1 = Context.AllocateNamedDataSlot ("slot1");
Assert.Fail ("Exception expected");
}
catch {}
Context.FreeNamedDataSlot ("slot1");
Context.FreeNamedDataSlot ("slot2");
try
{
namedSlot1 = Context.AllocateNamedDataSlot ("slot1");
}
catch
{
Assert.Fail ("Exception not expected");
}
Context.FreeNamedDataSlot ("slot1");
}
void CheckOtherContextDatastore ()
{
LocalDataStoreSlot namedSlot1 = Context.GetNamedDataSlot ("slot1");
LocalDataStoreSlot namedSlot2 = Context.GetNamedDataSlot ("slot2");
Assert.IsTrue (Context.GetData (slot) == null, "Slot already has data");
Assert.IsTrue (Context.GetData (namedSlot1) == null, "Slot already has data");
Assert.IsTrue (Context.GetData (namedSlot2) == null, "Slot already has data");
Context.SetData (slot, "other data");
Context.SetData (namedSlot1, "other data1");
Context.SetData (namedSlot2, "other data2");
}
}
}

View File

@@ -0,0 +1,231 @@
//
// MonoTests.System.Runtime.Remoting.SoapServicesTest.cs
//
// Author: Lluis Sanchez Gual (lluis@ximian.com)
//
// 2003 (C) Copyright, Novell, Inc.
//
using System;
using System.Reflection;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Metadata;
using NUnit.Framework;
namespace MonoTests.System.Runtime.Remoting
{
[SoapTypeAttribute (XmlElementName="ename", XmlNamespace="ens", XmlTypeName="tname", XmlTypeNamespace="tns")]
public class SoapTest
{
[SoapField(XmlElementName="atrib",XmlNamespace="ns1",UseAttribute=true)]
public string atribut;
[SoapField(XmlElementName="elem",XmlNamespace="ns1")]
public int element;
[SoapField(XmlElementName="elem2")]
public int element2;
[SoapMethod (SoapAction="myaction")]
public void FesAlgo ()
{
}
public void FesAlgoMes ()
{
}
public void FesAlgoMesEspecial ()
{
}
}
public class SoapTest1
{
}
[SoapTypeAttribute (XmlElementName="ename", XmlTypeName="tname")]
public class SoapTest2
{
}
[SoapTypeAttribute (XmlNamespace="ens", XmlTypeNamespace="tns")]
public class SoapTest3
{
}
[TestFixture]
public class SoapServicesTest
{
public string ThisNamespace
{
get
{
string tn = "http://schemas.microsoft.com/clr/nsassem/";
tn += GetType ().Namespace + "/" + GetType ().Assembly.GetName().Name;
return tn;
}
}
public string GetClassNs (Type t)
{
string tn = "http://schemas.microsoft.com/clr/nsassem/";
tn += t.FullName + "/" + t.Assembly.GetName().Name;
return tn;
}
public string GetSimpleTypeName (Type t)
{
return t.FullName + ", " + t.Assembly.GetName().Name;
}
[Test]
public void TestGetXmlType ()
{
bool res;
string name, ns;
// XmlType
res = SoapServices.GetXmlElementForInteropType (typeof(SoapTest), out name, out ns);
Assert.IsTrue (res, "E1");
Assert.AreEqual ("ename", name, "E2");
Assert.AreEqual ("ens", ns, "E3");
res = SoapServices.GetXmlElementForInteropType (typeof(SoapTest1), out name, out ns);
Assert.IsTrue (!res, "E4");
res = SoapServices.GetXmlElementForInteropType (typeof(SoapTest2), out name, out ns);
Assert.IsTrue (res, "E5");
Assert.AreEqual ("ename", name, "E6");
Assert.AreEqual (ThisNamespace, ns, "E7");
res = SoapServices.GetXmlElementForInteropType (typeof(SoapTest3), out name, out ns);
Assert.IsTrue (res, "E8");
Assert.AreEqual ("SoapTest3", name, "E9");
Assert.AreEqual ("ens", ns, "E10");
// XmlElement
res = SoapServices.GetXmlTypeForInteropType (typeof(SoapTest), out name, out ns);
Assert.IsTrue (res, "T1");
Assert.AreEqual ("tname", name, "T2");
Assert.AreEqual ("tns", ns, "T3");
res = SoapServices.GetXmlTypeForInteropType (typeof(SoapTest1), out name, out ns);
Assert.IsTrue (!res, "T4");
res = SoapServices.GetXmlTypeForInteropType (typeof(SoapTest2), out name, out ns);
Assert.IsTrue (res, "T5");
Assert.AreEqual ("tname", name, "T6");
Assert.AreEqual (ThisNamespace, ns, "T7");
res = SoapServices.GetXmlTypeForInteropType (typeof(SoapTest3), out name, out ns);
Assert.IsTrue (res, "T8");
Assert.AreEqual ("SoapTest3", name, "T9");
Assert.AreEqual ("tns", ns, "T10");
}
[Test]
public void TestGetInteropType ()
{
Type t;
// Manual registration
t = SoapServices.GetInteropTypeFromXmlElement ("aa","bb");
Assert.AreEqual (t, null, "M1");
SoapServices.RegisterInteropXmlElement ("aa","bb",typeof(SoapTest));
t = SoapServices.GetInteropTypeFromXmlElement ("aa","bb");
Assert.AreEqual (typeof (SoapTest), t, "M2");
t = SoapServices.GetInteropTypeFromXmlType ("aa","bb");
Assert.AreEqual (null, t, "M3");
SoapServices.RegisterInteropXmlType ("aa","bb",typeof(SoapTest));
t = SoapServices.GetInteropTypeFromXmlType ("aa","bb");
Assert.AreEqual (typeof (SoapTest), t, "M4");
// Preload type
SoapServices.PreLoad (typeof(SoapTest2));
t = SoapServices.GetInteropTypeFromXmlElement ("ename",ThisNamespace);
Assert.AreEqual (typeof (SoapTest2), t, "T1");
t = SoapServices.GetInteropTypeFromXmlType ("tname",ThisNamespace);
Assert.AreEqual (typeof (SoapTest2), t, "T2");
// Preload assembly
SoapServices.PreLoad (typeof(SoapTest).Assembly);
t = SoapServices.GetInteropTypeFromXmlElement ("SoapTest3","ens");
Assert.AreEqual (typeof (SoapTest3), t, "A1");
t = SoapServices.GetInteropTypeFromXmlType ("SoapTest3","tns");
Assert.AreEqual (typeof (SoapTest3), t, "A2");
}
[Test]
public void TestSoapFields ()
{
string name;
Type t;
SoapServices.GetInteropFieldTypeAndNameFromXmlAttribute (typeof(SoapTest), "atrib", "ns1", out t, out name);
Assert.AreEqual ("atribut", name, "#1");
Assert.AreEqual (typeof(string), t, "#2");
SoapServices.GetInteropFieldTypeAndNameFromXmlElement (typeof(SoapTest), "elem", "ns1", out t, out name);
Assert.AreEqual ("element", name, "#3");
Assert.AreEqual (typeof(int), t, "#4");
SoapServices.GetInteropFieldTypeAndNameFromXmlElement (typeof(SoapTest), "elem2", null, out t, out name);
Assert.AreEqual ("element2", name, "#5");
Assert.AreEqual (typeof(int), t, "#6");
}
[Test]
[Category("NotWorking")]
public void TestSoapActions ()
{
string act;
MethodBase mb;
mb = typeof(SoapTest).GetMethod ("FesAlgo");
act = SoapServices.GetSoapActionFromMethodBase (mb);
Assert.AreEqual ("myaction", act, "S1");
mb = typeof(SoapTest).GetMethod ("FesAlgoMes");
SoapServices.RegisterSoapActionForMethodBase (mb, "anotheraction");
act = SoapServices.GetSoapActionFromMethodBase (mb);
Assert.AreEqual ("anotheraction", act, "S2");
mb = typeof(SoapTest).GetMethod ("FesAlgoMesEspecial");
act = SoapServices.GetSoapActionFromMethodBase (mb);
Assert.AreEqual (GetClassNs (typeof(SoapTest))+ "#FesAlgoMesEspecial", act, "S3");
string typeName, methodName;
bool res;
res = SoapServices.GetTypeAndMethodNameFromSoapAction ("myaction", out typeName, out methodName);
Assert.IsTrue (res, "M1");
Assert.AreEqual (GetSimpleTypeName (typeof(SoapTest)), typeName, "M2");
Assert.AreEqual ("FesAlgo", methodName, "M3");
res = SoapServices.GetTypeAndMethodNameFromSoapAction ("anotheraction", out typeName, out methodName);
Assert.IsTrue (res, "M4");
Assert.AreEqual (GetSimpleTypeName (typeof(SoapTest)), typeName, "M5");
Assert.AreEqual ("FesAlgoMes", methodName, "M6");
res = SoapServices.GetTypeAndMethodNameFromSoapAction (GetClassNs (typeof(SoapTest))+ "#FesAlgoMesEspecial", out typeName, out methodName);
Assert.IsTrue (res, "M7");
Assert.AreEqual (GetSimpleTypeName (typeof(SoapTest)), typeName, "M8");
Assert.AreEqual ("FesAlgoMesEspecial", methodName, "M9");
}
}
}

View File

@@ -0,0 +1,369 @@
//
// MonoTests.System.Runtime.Remoting.SynchronizationAttributeTest.cs
//
// Author: Lluis Sanchez Gual (lluis@ximian.com)
//
// 2003 (C) Copyright, Novell, Inc.
//
using System;
using System.Threading;
using System.Runtime.Remoting.Contexts;
using NUnit.Framework;
namespace MonoTests.System.Runtime.Remoting
{
enum SynchRes { SameSync, NewSync, NoSync }
class SincroBase: ContextBoundObject
{
public int idx = 0;
public bool CheckConcurrency ()
{
int t = idx;
for (int n=0; n<40; n++)
{
idx++;
Thread.Sleep (25);
}
return (t+40 != idx);
}
public bool CheckUnlockedConcurrency ()
{
Lock (false);
return CheckConcurrency ();
}
public SynchRes CheckContext (Context ctx)
{
object otherp = ctx.GetProperty ("Synchronization");
object thisp = Thread.CurrentContext.GetProperty ("Synchronization");
if (thisp == null) return SynchRes.NoSync;
if (thisp == otherp) return SynchRes.SameSync;
return SynchRes.NewSync;
}
public SynchRes CheckContextTransition (Type type)
{
SincroBase bob = (SincroBase)Activator.CreateInstance (type);
return bob.CheckContext (Thread.CurrentContext);
}
public bool CheckCalloutConcurrency (SincroBase bob)
{
bool res = bob.CheckConcurrency ();
return res;
}
public void CheckLock1 ()
{
Thread.Sleep (2000);
Lock (false);
Thread.Sleep (6000);
}
public void CheckLock2 ()
{
Thread.Sleep (1000);
Lock (true);
Thread.Sleep (2000);
}
public void Lock (bool b)
{
SynchronizationAttribute thisp = (SynchronizationAttribute) Thread.CurrentContext.GetProperty ("Synchronization");
thisp.Locked = b;
}
public bool GetLocked ()
{
SynchronizationAttribute thisp = (SynchronizationAttribute) Thread.CurrentContext.GetProperty ("Synchronization");
return thisp.Locked;
}
public bool CheckMonitorWait (bool exitContext)
{
lock (this)
{
return Monitor.Wait (this, 1000, exitContext);
}
}
public void CheckMonitorPulse ()
{
lock (this)
{
Monitor.Pulse (this);
}
}
}
[Synchronization (SynchronizationAttribute.SUPPORTED)]
class SincroSupported: SincroBase
{
}
[Synchronization (SynchronizationAttribute.REQUIRED)]
class SincroRequired: SincroBase
{
}
[Synchronization (SynchronizationAttribute.REQUIRES_NEW)]
class SincroRequiresNew: SincroBase
{
public bool TestCallback ()
{
SincroNotSupported bob = new SincroNotSupported ();
return bob.CallBack (this);
}
}
[Synchronization (SynchronizationAttribute.NOT_SUPPORTED)]
class SincroNotSupported: SincroBase
{
public bool CallBack (SincroRequiresNew bob)
{
return bob.CheckConcurrency ();
}
}
[Synchronization (SynchronizationAttribute.REQUIRES_NEW, true)]
class SincroRequiresNewReentrant: SincroBase
{
}
[TestFixture]
[Category ("MobileNotWorking")] // Bug #10267
public class SynchronizationAttributeTest
{
SincroRequiresNew sincob = new SincroRequiresNew ();
SincroNotSupported notsup = new SincroNotSupported ();
SincroRequiresNewReentrant reentrant = new SincroRequiresNewReentrant ();
SincroRequiresNew notreentrant = new SincroRequiresNew ();
bool otResult;
[Test]
public void TestSynchronization ()
{
Thread tr = new Thread (new ThreadStart (FirstSyncThread));
tr.Start ();
Thread.Sleep (200);
SecondSyncThread ();
tr.Join ();
Assert.IsTrue (!otResult, "Concurrency detected in FirstSyncThread");
}
void FirstSyncThread ()
{
otResult = sincob.CheckConcurrency ();
}
void SecondSyncThread ()
{
bool concurrent = sincob.CheckConcurrency ();
Assert.IsTrue (!concurrent, "Concurrency detected");
}
[Test]
public void TestSupported ()
{
SincroRequiresNew ob = new SincroRequiresNew ();
SynchRes res = ob.CheckContextTransition (typeof(SincroSupported));
Assert.IsTrue (res == SynchRes.SameSync, "Synchronizaton context expected");
SincroSupported ob2 = new SincroSupported ();
res = ob2.CheckContext (Thread.CurrentContext);
Assert.IsTrue (res == SynchRes.NoSync, "Synchronizaton context not expected");
}
[Test]
public void TestRequired ()
{
SincroRequiresNew ob = new SincroRequiresNew ();
SynchRes res = ob.CheckContextTransition (typeof(SincroRequired));
Assert.IsTrue (res == SynchRes.SameSync, "Synchronizaton context expected 1");
SincroRequired ob2 = new SincroRequired ();
res = ob2.CheckContext (Thread.CurrentContext);
Assert.IsTrue (res == SynchRes.NewSync, "Synchronizaton context expected 2");
}
[Test]
public void TestRequiresNew ()
{
SincroRequiresNew ob = new SincroRequiresNew ();
SynchRes res = ob.CheckContextTransition (typeof(SincroRequiresNew));
Assert.IsTrue (res == SynchRes.NewSync, "New synchronizaton context expected");
SincroRequiresNew ob2 = new SincroRequiresNew ();
res = ob2.CheckContext (Thread.CurrentContext);
Assert.IsTrue (res == SynchRes.NewSync, "Synchronizaton context not expected");
}
[Test]
public void TestNotSupported ()
{
SincroRequiresNew ob = new SincroRequiresNew ();
SynchRes res = ob.CheckContextTransition (typeof(SincroNotSupported));
Assert.IsTrue (res == SynchRes.NoSync, "Synchronizaton context not expected 1");
SincroNotSupported ob2 = new SincroNotSupported ();
res = ob2.CheckContext (Thread.CurrentContext);
Assert.IsTrue (res == SynchRes.NoSync, "Synchronizaton context not expected 2");
}
[Test]
public void TestLocked1 ()
{
sincob.Lock (false);
Thread tr = new Thread (new ThreadStart (FirstSyncThread));
tr.Start ();
Thread.Sleep (200);
SecondSyncThread ();
tr.Join ();
Assert.IsTrue (!otResult, "Concurrency detected in FirstSyncThread");
}
[Test]
public void TestLocked2 ()
{
Thread tr = new Thread (new ThreadStart (FirstNotSyncThread));
tr.Start ();
Thread.Sleep (200);
SecondNotSyncThread ();
tr.Join ();
Assert.IsTrue (otResult, "Concurrency not detected in FirstReentryThread");
}
void FirstNotSyncThread ()
{
otResult = sincob.CheckUnlockedConcurrency ();
}
void SecondNotSyncThread ()
{
bool concurrent = sincob.CheckConcurrency ();
Assert.IsTrue (concurrent, "Concurrency not detected");
}
[Test]
public void TestLocked3 ()
{
Thread tr = new Thread (new ThreadStart (Lock1Thread));
tr.Start ();
Thread.Sleep (200);
Lock2Thread ();
}
void Lock1Thread ()
{
sincob.CheckLock1 ();
}
void Lock2Thread ()
{
sincob.CheckLock2 ();
}
[Test]
public void TestReentry ()
{
Thread tr = new Thread (new ThreadStart (FirstReentryThread));
tr.Start ();
Thread.Sleep (200);
SecondReentryThread ();
tr.Join ();
Assert.IsTrue (otResult, "Concurrency not detected in FirstReentryThread");
}
void FirstReentryThread ()
{
otResult = reentrant.CheckCalloutConcurrency (notsup);
}
void SecondReentryThread ()
{
bool concurrent = reentrant.CheckCalloutConcurrency (notsup);
Assert.IsTrue (concurrent, "Concurrency not detected");
}
[Test]
public void TestNoReentry ()
{
Thread tr = new Thread (new ThreadStart (FirstNoReentryThread));
tr.Start ();
Thread.Sleep (200);
SecondNoReentryThread ();
tr.Join ();
Assert.IsTrue (!otResult, "Concurrency detected in FirstNoReentryThread");
}
void FirstNoReentryThread ()
{
otResult = notreentrant.CheckCalloutConcurrency (notsup);
}
void SecondNoReentryThread ()
{
bool concurrent = notreentrant.CheckCalloutConcurrency (notsup);
Assert.IsTrue (!concurrent, "Concurrency detected");
}
[Test]
public void TestCallback ()
{
Thread tr = new Thread (new ThreadStart (CallbackThread));
tr.Start ();
Thread.Sleep (200);
bool concurrent = notreentrant.CheckConcurrency ();
Assert.IsTrue (!concurrent, "Concurrency detected");
notreentrant.CheckContext (Thread.CurrentContext);
tr.Join ();
Assert.IsTrue (!otResult, "Concurrency detected in CallbackThread");
}
void CallbackThread ()
{
otResult = notreentrant.TestCallback ();
}
[Test]
[Category("NotDotNet")]
[Category ("MobileNotWorking")]
public void TestMonitorWait ()
{
Thread tr = new Thread (new ThreadStart (DoMonitorPulse));
tr.Start ();
bool r = sincob.CheckMonitorWait (true);
Assert.IsTrue (r, "Wait timeout");
r = tr.Join (1000);
Assert.IsTrue (r, "Join timeout");
tr = new Thread (new ThreadStart (DoMonitorPulse));
tr.Start ();
r = sincob.CheckMonitorWait (false);
Assert.IsTrue (!r, "Expected wait timeout");
r = tr.Join (1000);
Assert.IsTrue (r, "Join timeout 2");
}
void DoMonitorPulse ()
{
Thread.Sleep (100);
sincob.CheckMonitorPulse ();
}
}
}