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

@@ -39,10 +39,7 @@ using System.Xml;
using NUnit.Framework;
using MonoTests.Helpers;
#if NET_4_0
using System.Security.Authentication.ExtendedProtection;
#endif
namespace MonoTests.System.ServiceModel.Channels
{
@@ -471,10 +468,8 @@ namespace MonoTests.System.ServiceModel.Channels
http_binding_element.TransferMode = TransferMode.Streamed;
http_binding_element.UnsafeConnectionNtlmAuthentication = !http_binding_element.UnsafeConnectionNtlmAuthentication;
http_binding_element.UseDefaultWebProxy = !http_binding_element.UseDefaultWebProxy;
#if NET_4_0
http_binding_element.DecompressionEnabled = !http_binding_element.DecompressionEnabled;
http_binding_element.ExtendedProtectionPolicy = new ExtendedProtectionPolicy (PolicyEnforcement.WhenSupported);
#endif
//
// Actual call to ExportPolicy

View File

@@ -107,11 +107,9 @@ namespace MonoTests.System.ServiceModel.Channels
binding_element.TimeToLive = TimeSpan.FromSeconds (60);
binding_element.UseMsmqTracing = !binding_element.UseMsmqTracing;
binding_element.UseSourceJournal = !binding_element.UseSourceJournal;
#if NET_4_0
// This ones haven't been implemented yet, so comment them for now.
//binding_element.ReceiveContextEnabled = !binding_element.ReceiveContextEnabled;
//binding_element.ValidityDuration = TimeSpan.FromSeconds (30);
#endif
binding_element.MsmqTransportSecurity.MsmqAuthenticationMode = MsmqAuthenticationMode.Certificate;
binding_element.MsmqTransportSecurity.MsmqEncryptionAlgorithm = MsmqEncryptionAlgorithm.Aes;

View File

@@ -25,7 +25,6 @@
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#if NET_4_0
using System;
using System.Collections.Generic;
@@ -52,4 +51,3 @@ namespace MonoTests.System.ServiceModel.Configuration
}
}
}
#endif

View File

@@ -1009,5 +1009,82 @@ namespace MonoTests.System.ServiceModel.Description
[MyWebGet]
string Get ();
}
public interface IA1 : IB1, IB2
{
void MethodA1 ();
}
public interface IA2 : IB1, IB2
{
void MethodA2 ();
}
[ServiceContract]
public interface IB1 : IC1, IC2
{
[OperationContract]
void MethodB1 ();
}
[ServiceContract]
public interface IB2 : IC1, IC2
{
[OperationContract]
void MethodB2 ();
}
public interface IC1 {}
public interface IC2 {}
[ServiceContract]
public interface IS : IA1, IA2
{
[OperationContract]
void MethodS() ;
}
public class S : IS
{
#region IS implementation
public void MethodS ()
{
throw new NotImplementedException ();
}
#endregion
#region IA2 implementation
public void MethodA2 ()
{
throw new NotImplementedException ();
}
#endregion
#region IA1 implementation
public void MethodA1 ()
{
throw new NotImplementedException ();
}
#endregion
#region IB2 implementation
public void MethodB2 ()
{
throw new NotImplementedException ();
}
#endregion
#region IB1 implementation
public void MethodB1 ()
{
throw new NotImplementedException ();
}
#endregion
}
[Test]
public void DualSpreadingInheritanceTest()
{
var cd = ContractDescription.GetContract (typeof(S));
Assert.IsNotNull(cd);
Assert.IsTrue (cd.Name == "IS");
}
}
}

View File

@@ -38,21 +38,13 @@ using System.ServiceModel.Dispatcher;
using System.Text;
using NUnit.Framework;
using MonoTests.Helpers;
namespace MonoTests.System.ServiceModel.Description
{
[TestFixture]
public class MetadataExchangeBindingsTest
{
Uri CreateUri (string uriString)
{
var uri = new Uri (uriString);
var l = new TcpListener (uri.Port);
l.Start ();
l.Stop ();
return uri;
}
[Test]
public void CreateMexHttpBinding ()
{
@@ -69,7 +61,7 @@ namespace MonoTests.System.ServiceModel.Description
Assert.AreEqual (MessageVersion.Soap12WSAddressing10, b.GetProperty<MessageVersion> (new BindingParameterCollection ()), "#6");
var host = new ServiceHost (typeof (MetadataExchange));
host.AddServiceEndpoint (typeof (IMetadataExchange), MetadataExchangeBindings.CreateMexHttpBinding (), CreateUri ("http://localhost:30158"));
host.AddServiceEndpoint (typeof (IMetadataExchange), MetadataExchangeBindings.CreateMexHttpBinding (), "http://localhost:" + NetworkHelpers.FindFreePort ());
host.Open ();
try {
// it still does not rewrite MessageVersion.None. It's rather likely ServiceMetadataExtension which does overwriting.
@@ -96,7 +88,7 @@ namespace MonoTests.System.ServiceModel.Description
Assert.AreEqual(Uri.UriSchemeHttps, b.Scheme, "#8");
var host = new ServiceHost(typeof(MetadataExchange));
host.AddServiceEndpoint(typeof(IMetadataExchange), MetadataExchangeBindings.CreateMexHttpsBinding(), CreateUri("https://localhost:30158"));
host.AddServiceEndpoint(typeof(IMetadataExchange), MetadataExchangeBindings.CreateMexHttpsBinding(), "https://localhost:" + NetworkHelpers.FindFreePort ());
host.Open();
try
{

View File

@@ -57,18 +57,9 @@ namespace MonoTests.System.ServiceModel.Description
}
}
Uri CreateUri (string uriString)
{
var uri = new Uri (uriString);
var l = new TcpListener (uri.Port);
l.Start ();
l.Stop ();
return uri;
}
[Test]
public void InitializeRuntime1 () {
using (ServiceHost host = new ServiceHost (typeof (MyService), CreateUri ("http://localhost:" + NetworkHelpers.FindFreePort ()))) {
using (ServiceHost host = new ServiceHost (typeof (MyService), new Uri ("http://localhost:" + NetworkHelpers.FindFreePort ()))) {
host.AddServiceEndpoint (typeof (IMyContract), new BasicHttpBinding (), "e1");
Assert.AreEqual (0, host.ChannelDispatchers.Count, "ChannelDispatchers.Count #1");
@@ -105,7 +96,7 @@ namespace MonoTests.System.ServiceModel.Description
[Test]
public void InitializeRuntime2 () {
using (ServiceHost host = new ServiceHost (typeof (MyService), CreateUri ("http://localhost:" + NetworkHelpers.FindFreePort ()))) {
using (ServiceHost host = new ServiceHost (typeof (MyService), new Uri ("http://localhost:" + NetworkHelpers.FindFreePort ()))) {
host.AddServiceEndpoint (typeof (IMyContract), new BasicHttpBinding (), "");
host.Description.Behaviors.Remove<ServiceDebugBehavior> ();
@@ -124,7 +115,7 @@ namespace MonoTests.System.ServiceModel.Description
[Test]
public void InitializeRuntime3 () {
using (ServiceHost host = new ServiceHost (typeof (MyService), CreateUri ("http://localhost:" + NetworkHelpers.FindFreePort ()))) {
using (ServiceHost host = new ServiceHost (typeof (MyService), new Uri ("http://localhost:" + NetworkHelpers.FindFreePort ()))) {
host.AddServiceEndpoint (typeof (IMyContract), new BasicHttpBinding (), "");
host.Description.Behaviors.Find<ServiceDebugBehavior> ().HttpHelpPageEnabled = false;
@@ -143,7 +134,7 @@ namespace MonoTests.System.ServiceModel.Description
[Test]
public void InitializeRuntime4 () {
int port = NetworkHelpers.FindFreePort ();
using (ServiceHost host = new ServiceHost (typeof (MyService), CreateUri ("http://localhost:" + port))) {
using (ServiceHost host = new ServiceHost (typeof (MyService), new Uri ("http://localhost:" + port))) {
host.AddServiceEndpoint (typeof (IMyContract), new BasicHttpBinding (), "");
host.Description.Behaviors.Find<ServiceDebugBehavior> ().HttpHelpPageUrl = new Uri ("http://localhost:" + port + "/help");
@@ -190,7 +181,7 @@ namespace MonoTests.System.ServiceModel.Description
[Test]
public void ServiceMetadataExtension1 () {
int port = NetworkHelpers.FindFreePort ();
using (ServiceHost host = new ServiceHost (typeof (MyService), CreateUri ("http://localhost:" + port))) {
using (ServiceHost host = new ServiceHost (typeof (MyService), new Uri ("http://localhost:" + port))) {
host.AddServiceEndpoint (typeof (IMyContract), new BasicHttpBinding (), "");
host.Description.Behaviors.Find<ServiceDebugBehavior> ().HttpHelpPageUrl = new Uri ("http://localhost:" + port + "/help");
try {
@@ -207,9 +198,9 @@ namespace MonoTests.System.ServiceModel.Description
[Test]
public void ServiceMetadataExtension2 () {
int port = NetworkHelpers.FindFreePort ();
using (ServiceHost host = new ServiceHost (typeof (MyService), CreateUri ("http://localhost:" + port))) {
using (ServiceHost host = new ServiceHost (typeof (MyService), new Uri ("http://localhost:" + port))) {
host.AddServiceEndpoint (typeof (IMyContract), new BasicHttpBinding (), "");
host.Description.Behaviors.Find<ServiceDebugBehavior> ().HttpHelpPageUrl = CreateUri ("http://localhost:" + port + "/help");
host.Description.Behaviors.Find<ServiceDebugBehavior> ().HttpHelpPageUrl = new Uri ("http://localhost:" + port + "/help");
ServiceMetadataExtension extension = new ServiceMetadataExtension ();
host.Extensions.Add (extension);

View File

@@ -25,7 +25,6 @@
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#if NET_4_0
using System;
using System.Collections.Generic;
@@ -54,4 +53,3 @@ namespace MonoTests.System.ServiceModel.Description
}
}
}
#endif

View File

@@ -23,6 +23,7 @@
// THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
@@ -62,16 +63,24 @@ namespace MonoTests.System.ServiceModel.Dispatcher
var client = new TempConvertSoapClient (binding, remoteAddress);
var wait = new ManualResetEvent (false);
Exception error = null;
string result = null;
client.CelsiusToFahrenheitCompleted += delegate (object o, CelsiusToFahrenheitCompletedEventArgs e) {
if (e.Error != null)
throw e.Error;
Assert.AreEqual ("76.1", e.Result, "#1");
wait.Set ();
try {
error = e.Error;
result = e.Error == null ? e.Result : null;
} finally {
wait.Set ();
}
};
client.CelsiusToFahrenheitAsync ("24.5");
if (!wait.WaitOne (TimeSpan.FromSeconds (20)))
Assert.Fail ("timeout");
Assert.IsTrue (wait.WaitOne (TimeSpan.FromSeconds (20)), "timeout");
Assert.IsNull (error, "#1, inner exception: {0}", error);
Assert.AreEqual ("76.1", result, "#2");
} finally {
serviceHost.Close ();
}
@@ -81,16 +90,16 @@ namespace MonoTests.System.ServiceModel.Dispatcher
{
public FahrenheitToCelsiusResponse FarenheitToCelsius (FahrenheitToCelsiusRequest request)
{
var farenheit = double.Parse (request.Body.Fahrenheit);
var farenheit = double.Parse (request.Body.Fahrenheit, CultureInfo.InvariantCulture);
var celsius = ((farenheit - 32) / 9) * 5;
return new FahrenheitToCelsiusResponse (new FahrenheitToCelsiusResponseBody (celsius.ToString ()));
return new FahrenheitToCelsiusResponse (new FahrenheitToCelsiusResponseBody (celsius.ToString (CultureInfo.InvariantCulture)));
}
public CelsiusToFahrenheitResponse CelsiusToFarenheit (CelsiusToFahrenheitRequest request)
{
var celsius = double.Parse (request.Body.Celsius);
var celsius = double.Parse (request.Body.Celsius, CultureInfo.InvariantCulture);
var farenheit = ((celsius * 9) / 5) + 32;
return new CelsiusToFahrenheitResponse (new CelsiusToFahrenheitResponseBody (farenheit.ToString ()));
return new CelsiusToFahrenheitResponse (new CelsiusToFahrenheitResponseBody (farenheit.ToString (CultureInfo.InvariantCulture)));
}
Func<FahrenheitToCelsiusRequest,FahrenheitToCelsiusResponse> farenheitToCelsius;

View File

@@ -57,6 +57,7 @@ namespace MonoTests.System.ServiceModel.Dispatcher
serviceHost.AddServiceEndpoint (typeof (IMetadataExchange), MetadataExchangeBindings.CreateMexHttpBinding (), "mex");
serviceHost.Open ();
Thread.Sleep (2000); // let WCF spin up
try {
// client
@@ -65,16 +66,24 @@ namespace MonoTests.System.ServiceModel.Dispatcher
var client = new Service1Client (binding, remoteAddress);
var wait = new ManualResetEvent (false);
Exception error = null;
object result = null;
client.GetDataCompleted += delegate (object o, GetDataCompletedEventArgs e) {
if (e.Error != null)
throw e.Error;
Assert.AreEqual ("A", ((DataType1) e.Result).Id, "#1");
wait.Set ();
try {
error = e.Error;
result = e.Error == null ? e.Result : null;
} finally {
wait.Set ();
}
};
client.GetDataAsync ();
if (!wait.WaitOne (TimeSpan.FromSeconds (20)))
Assert.Fail ("timeout");
Assert.IsTrue (wait.WaitOne (TimeSpan.FromSeconds (20)), "timeout");
Assert.IsNull (error, "#1, inner exception: {0}", error);
Assert.AreEqual ("A", ((DataType1) result).Id, "#2");
} finally {
serviceHost.Close ();
}

View File

@@ -1,4 +1,3 @@
#if NET_4_0
//
// Authors:
// David Straw
@@ -77,58 +76,85 @@ namespace MonoTests.System.ServiceModel.Dispatcher
var nestedClient = new Service1Client (binding, remoteAddress);
var dbClient = new Service1Client (binding, remoteAddress);
var waits = new ManualResetEvent [4];
for (int i = 0; i < waits.Length; i++)
waits [i] = new ManualResetEvent (false);
{
ManualResetEvent wait = new ManualResetEvent (false);
Exception error = null;
object result = null;
int passed = 0;
normalClient.GetDataCompleted += delegate (object o, GetDataCompletedEventArgs e) {
try {
error = e.Error;
result = e.Error == null ? e.Result : null;
} finally {
wait.Set ();
}
};
normalClient.GetDataAsync ();
normalClient.GetDataCompleted += delegate (object o, GetDataCompletedEventArgs e) {
if (e.Error != null) {
Assert.Fail ("Normal failed; error: {0}", e.Error);
throw e.Error;
}
Assert.AreEqual ("A", ((DataType1) e.Result).Id, "Normal");
Interlocked.Increment (ref passed);
waits [0].Set ();
};
normalClient.GetDataAsync ();
Assert.IsTrue (wait.WaitOne (TimeSpan.FromSeconds (20)), "#1 timeout");
Assert.IsNull (error, "#1.1, inner exception: {0}", error);
Assert.AreEqual ("A", ((DataType1) result).Id, "#1.2");
}
collectionClient.GetCollectionDataCompleted += delegate (object sender, GetCollectionDataCompletedEventArgs e) {
if (e.Error != null) {
Assert.Fail ("Collection failed; error: {0}", e.Error);
throw e.Error;
}
Assert.AreEqual ("B,C", ItemsToString (e.Result.Cast<DataType1> ()), "Collection");
Interlocked.Increment (ref passed);
waits [1].Set ();
};
collectionClient.GetCollectionDataAsync ();
{
ManualResetEvent wait = new ManualResetEvent (false);
Exception error = null;
ObservableCollection<object> result = null;
nestedClient.GetNestedDataCompleted += delegate (object sender, GetNestedDataCompletedEventArgs e) {
if (e.Error != null) {
Assert.Fail ("Nested failed; error: {0}", e.Error);
throw e.Error;
}
Assert.AreEqual ("D,E", ItemsToString (e.Result.Items.Cast<DataType1> ()), "Nested");
Interlocked.Increment (ref passed);
waits [2].Set ();
};
nestedClient.GetNestedDataAsync ();
collectionClient.GetCollectionDataCompleted += delegate (object sender, GetCollectionDataCompletedEventArgs e) {
try {
error = e.Error;
result = e.Error == null ? e.Result : null;
} finally {
wait.Set ();
}
};
collectionClient.GetCollectionDataAsync ();
dbClient.JSMGetDatabasesCompleted += delegate (object sender, JSMGetDatabasesCompletedEventArgs e) {
waits [3].Set ();
if (e.Error != null) {
throw e.Error;
}
Assert.AreEqual ("databases", e.Result, "Databases");
Interlocked.Increment (ref passed);
};
dbClient.JSMGetDatabasesAsync();
Assert.IsTrue (wait.WaitOne (TimeSpan.FromSeconds (20)), "#2 timeout");
Assert.IsNull (error, "#2.1, inner exception: {0}", error);
Assert.AreEqual ("B,C", ItemsToString (result.Cast<DataType1> ()), "#2.2");
}
WaitHandle.WaitAll (waits, TimeSpan.FromMinutes (1));
if (passed != waits.Length)
Assert.Fail ("Not all tests passed!");
{
ManualResetEvent wait = new ManualResetEvent (false);
Exception error = null;
WebServiceMoonlightTest.ServiceReference2.DataType2 result = null;
nestedClient.GetNestedDataCompleted += delegate (object sender, GetNestedDataCompletedEventArgs e) {
try {
error = e.Error;
result = e.Error == null ? e.Result : null;
} finally {
wait.Set ();
}
};
nestedClient.GetNestedDataAsync ();
Assert.IsTrue (wait.WaitOne (TimeSpan.FromSeconds (20)), "#3 timeout");
Assert.IsNull (error, "#3.1, inner exception: {0}", error);
Assert.AreEqual ("D,E", ItemsToString (result.Items.Cast<DataType1> ()), "#3.2");
}
{
ManualResetEvent wait = new ManualResetEvent (false);
Exception error = null;
string result = null;
dbClient.JSMGetDatabasesCompleted += delegate (object sender, JSMGetDatabasesCompletedEventArgs e) {
try {
error = e.Error;
result = e.Error == null ? e.Result : null;
} finally {
wait.Set ();
}
};
dbClient.JSMGetDatabasesAsync();
Assert.IsTrue (wait.WaitOne (TimeSpan.FromSeconds (20)), "#4 timeout");
Assert.IsNull (error, "#4.1, inner exception: {0}", error);
Assert.AreEqual ("databases", result, "#4.2");
}
}
string ItemsToString (IEnumerable<DataType1> items)
@@ -857,4 +883,3 @@ namespace WebServiceMoonlightTest.ServiceReference2 {
}
}
#endif

View File

@@ -17,19 +17,6 @@ namespace MonoTests.System.ServiceModel.Dispatcher
[TestFixture]
public class ChannelDispatcherTest
{
Uri CreateAvailableUri (string uriString)
{
var uri = new Uri (uriString);
try {
var t = new TcpListener (uri.Port);
t.Start ();
t.Stop ();
} catch (Exception ex) {
Assert.Fail (String.Format ("Port {0} is not open. It is likely previous tests have failed and the port is kept opened", uri.Port));
}
return uri;
}
[Test]
public void ConstructorNullBindingName ()
{
@@ -44,7 +31,7 @@ namespace MonoTests.System.ServiceModel.Dispatcher
var st = cd.ServiceThrottle;
Assert.IsNull (st, "#0");
var uri = CreateAvailableUri ("http://localhost:" + NetworkHelpers.FindFreePort ());
var uri = new Uri ("http://localhost:" + NetworkHelpers.FindFreePort ());
ServiceHost h = new ServiceHost (typeof (TestContract), uri);
h.AddServiceEndpoint (typeof (TestContract).FullName, new BasicHttpBinding (), "address");
h.ChannelDispatchers.Add (cd);
@@ -71,7 +58,7 @@ namespace MonoTests.System.ServiceModel.Dispatcher
[Test]
public void Collection_Add_Remove () {
Console.WriteLine ("STart test Collection_Add_Remove");
var uri = CreateAvailableUri ("http://localhost:" + NetworkHelpers.FindFreePort ());
var uri = new Uri ("http://localhost:" + NetworkHelpers.FindFreePort ());
ServiceHost h = new ServiceHost (typeof (TestContract), uri);
h.AddServiceEndpoint (typeof (TestContract).FullName, new BasicHttpBinding (), "address");
MyChannelDispatcher d = new MyChannelDispatcher (new MyChannelListener (uri));
@@ -89,7 +76,7 @@ namespace MonoTests.System.ServiceModel.Dispatcher
[Test]
public void EndpointDispatcherAddTest ()
{
var uri = CreateAvailableUri ("http://localhost:" + NetworkHelpers.FindFreePort ());
var uri = new Uri ("http://localhost:" + NetworkHelpers.FindFreePort ());
MyChannelDispatcher d = new MyChannelDispatcher (new MyChannelListener (uri));
d.Endpoints.Add (new EndpointDispatcher (new EndpointAddress (uri), "", ""));
}
@@ -97,7 +84,7 @@ namespace MonoTests.System.ServiceModel.Dispatcher
[Test]
[ExpectedException (typeof (InvalidOperationException))]
public void EndpointDispatcherAddTest2 () {
var uri = CreateAvailableUri ("http://localhost:" + NetworkHelpers.FindFreePort ());
var uri = new Uri ("http://localhost:" + NetworkHelpers.FindFreePort ());
MyChannelDispatcher d = new MyChannelDispatcher (new MyChannelListener (uri));
d.Endpoints.Add (new EndpointDispatcher (new EndpointAddress (uri), "", ""));
d.Open (); // the dispatcher must be attached.
@@ -107,7 +94,7 @@ namespace MonoTests.System.ServiceModel.Dispatcher
[ExpectedException (typeof (InvalidOperationException))]
public void EndpointDispatcherAddTest3 ()
{
var uri = CreateAvailableUri ("http://localhost:" + NetworkHelpers.FindFreePort ());
var uri = new Uri ("http://localhost:" + NetworkHelpers.FindFreePort ());
ServiceHost h = new ServiceHost (typeof (TestContract), uri);
MyChannelDispatcher d = new MyChannelDispatcher (new MyChannelListener (uri));
d.Endpoints.Add (new EndpointDispatcher (new EndpointAddress (uri), "", ""));
@@ -119,7 +106,7 @@ namespace MonoTests.System.ServiceModel.Dispatcher
[ExpectedException (typeof (InvalidOperationException))] // i.e. it is thrown synchronously in current thread.
public void EndpointDispatcherAddTest4 ()
{
var uri = CreateAvailableUri ("http://localhost:" + NetworkHelpers.FindFreePort ());
var uri = new Uri ("http://localhost:" + NetworkHelpers.FindFreePort ());
ServiceHost h = new ServiceHost (typeof (TestContract), uri);
var listener = new MyChannelListener (uri);
MyChannelDispatcher d = new MyChannelDispatcher (listener);
@@ -151,7 +138,7 @@ namespace MonoTests.System.ServiceModel.Dispatcher
[ExpectedException (typeof (InvalidOperationException))] // i.e. it is thrown synchronously in current thread.
public void EndpointDispatcherAddTest5 ()
{
var uri = CreateAvailableUri ("http://localhost:" + NetworkHelpers.FindFreePort ());
var uri = new Uri ("http://localhost:" + NetworkHelpers.FindFreePort ());
ServiceHost h = new ServiceHost (typeof (TestContract), uri);
var binding = new BasicHttpBinding ();
var listener = new MyChannelListener (uri);
@@ -173,7 +160,7 @@ namespace MonoTests.System.ServiceModel.Dispatcher
[Test]
public void EndpointDispatcherAddTest6 ()
{
var uri = CreateAvailableUri ("http://localhost:" + NetworkHelpers.FindFreePort ());
var uri = new Uri ("http://localhost:" + NetworkHelpers.FindFreePort ());
ServiceHost h = new ServiceHost (typeof (TestContract), uri);
var binding = new BasicHttpBinding ();
var listener = new MyChannelListener<IReplyChannel> (uri);
@@ -204,7 +191,7 @@ namespace MonoTests.System.ServiceModel.Dispatcher
[ExpectedException (typeof (InvalidOperationException))]
public void EndpointDispatcherAddTest7 ()
{
var uri = CreateAvailableUri ("http://localhost:" + NetworkHelpers.FindFreePort ());
var uri = new Uri ("http://localhost:" + NetworkHelpers.FindFreePort ());
ServiceHost h = new ServiceHost (typeof (TestContract), uri);
var binding = new BasicHttpBinding ();
var listener = new MyChannelListener<IReplyChannel> (uri);
@@ -239,7 +226,7 @@ namespace MonoTests.System.ServiceModel.Dispatcher
// but it makes little sense especially for checking duplicate listen URIs. Duplicate listen URIs should be rejected anyways.
public void EndpointDispatcherAddTest8 ()
{
var uri = CreateAvailableUri ("http://localhost:" + NetworkHelpers.FindFreePort ());
var uri = new Uri ("http://localhost:" + NetworkHelpers.FindFreePort ());
ServiceHost h = new ServiceHost (typeof (TestContract), uri);
var listener = new MyChannelListener<IReplyChannel> (uri);
MyChannelDispatcher d = new MyChannelDispatcher (listener);
@@ -284,7 +271,7 @@ namespace MonoTests.System.ServiceModel.Dispatcher
// [Test]
public void EndpointDispatcherAddTest9 () // test singleton service
{
var uri = CreateAvailableUri ("http://localhost:" + NetworkHelpers.FindFreePort ());
var uri = new Uri ("http://localhost:" + NetworkHelpers.FindFreePort ());
ServiceHost h = new ServiceHost (new TestContract (), uri);
h.Description.Behaviors.Find<ServiceBehaviorAttribute> ().InstanceContextMode = InstanceContextMode.Single;
var listener = new MyChannelListener<IReplyChannel> (uri);

View File

@@ -434,14 +434,12 @@ namespace MonoTests.System.ServiceModel
Assert.AreEqual ("callResult", res.val, "#2");
}
#if NET_4_0
[Test]
public void ConstructorServiceEndpoint ()
{
// It is okay to pass ServiceEndpoint that does not have Binding or EndpointAddress.
new ChannelFactory<IRequestChannel> (new ServiceEndpoint (ContractDescription.GetContract (typeof (IMetadataExchange)), null, null));
}
#endif
public T CreateFooComplexMC_Channel<T> (bool isXml)
{

View File

@@ -28,12 +28,16 @@
using System;
using System.Collections.ObjectModel;
using System.IO;
using System.Net;
using System.Net.Sockets;
using System.Reflection;
using System.ServiceModel;
using System.ServiceModel.Channels;
using System.ServiceModel.Description;
using System.Text;
using System.Threading.Tasks;
using System.Xml;
using System.Xml.Serialization;
using NUnit.Framework;
using MonoTests.Helpers;
@@ -479,7 +483,6 @@ namespace MonoTests.System.ServiceModel
}
}
#if NET_4_0
[Test]
public void ConstructorServiceEndpoint ()
{
@@ -504,6 +507,82 @@ namespace MonoTests.System.ServiceModel
{
}
}
#endif
[SerializableAttribute ()]
[XmlTypeAttribute (Namespace = "http://mono.com/")]
public class ValueWithXmlAttributes
{
[XmlElementAttribute (ElementName = "Name")]
public string FakeName;
}
[ServiceContractAttribute (Namespace = "http://mono.com/")]
public interface IXmlSerializerFormatService
{
[OperationContractAttribute (Action = "http://mono.com/Send", ReplyAction = "*")]
[XmlSerializerFormatAttribute ()]
void SendValueWithXmlAttributes (ValueWithXmlAttributes v);
}
class XmlSerializerFormatClient : ClientBase<IXmlSerializerFormatService>
{
public XmlSerializerFormatClient (Binding binding, EndpointAddress address)
: base (binding, address)
{
}
public void SendValue ()
{
var v = new ValueWithXmlAttributes () { FakeName = "name" };
base.Channel.SendValueWithXmlAttributes (v);
}
}
[Test]
public void TestXmlAttributes ()
{
int port = NetworkHelpers.FindFreePort();
var endpoint = new EndpointAddress ("http://localhost:" + port);
var binding = new BasicHttpBinding ();
var client = new XmlSerializerFormatClient (binding, endpoint);
var server = new TcpListener (IPAddress.Any, port);
server.Start ();
var acceptTask = server.AcceptTcpClientAsync ();
var t1 = new Task( () => client.SendValue ());
t1.Start();
if (!acceptTask.Wait (2000))
Assert.Fail ("No request from client.");
var netStream = acceptTask.Result.GetStream ();
byte[] buffer = new byte [1024];
int numBytesRead = 0;
var message = new StringBuilder ();
do {
numBytesRead = netStream.Read (buffer, 0, buffer.Length);
var str = Encoding.UTF8.GetString (buffer, 0, numBytesRead);
message.AppendFormat ("{0}", str);
if (str.EndsWith ("</s:Envelope>", StringComparison.InvariantCulture))
break;
} while (numBytesRead > 0);
var messageStr = message.ToString ();
var envelopeIndex = messageStr.IndexOf ("<s:Envelope");
if (envelopeIndex < 0)
Assert.Fail ("Soap envelope was not received.");
var envelope = messageStr.Substring (envelopeIndex);
var expected = "<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\"><s:Body xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"><SendValueWithXmlAttributes xmlns=\"http://mono.com/\"><v><Name>name</Name></v></SendValueWithXmlAttributes></s:Body></s:Envelope>";
Assert.AreEqual (expected, envelope);
server.Stop ();
}
}
}

View File

@@ -213,6 +213,13 @@ namespace MonoTests.System.ServiceModel
Assert.IsTrue (Foo.JoinCalled, "#2");
}
[Test]
public void ReaderQuotasDefault_Bug15153 ()
{
NetTcpBinding binding = new NetTcpBinding(SecurityMode.None);
binding.ReaderQuotas.MaxStringContentLength = 8192;
}
[ServiceContract]
public interface IFoo
{

View File

@@ -373,7 +373,6 @@ namespace MonoTests.System.ServiceModel
return host;
}
#if NET_4_0
[Test]
public void AddServiceEndpoint_Directly ()
{
@@ -422,7 +421,6 @@ namespace MonoTests.System.ServiceModel
var contract = ContractDescription.GetContract (typeof (INotImplementedService));
host.AddServiceEndpoint (new ServiceEndpoint (contract, binding, address));
}
#endif
#region helpers

View File

@@ -353,6 +353,29 @@ namespace MonoTests.System.ServiceModel
}
}
[Test]
public void InstanceWithSingletonMode_InheritServiceBehavior ()
{
// # 37035
var ep = NetworkHelpers.LocalEphemeralEndPoint ().ToString ();
ChildSingletonService instance = new ChildSingletonService ();
ServiceHost host = new ServiceHost (instance);
host.AddServiceEndpoint (typeof (SingletonService),
new BasicHttpBinding (),
new Uri ("http://" + ep + "/s3"));
try {
host.Open ();
} catch (InvalidOperationException ex) {
Assert.Fail ("InstanceContextMode was not inherited from parent, exception was: {0}", ex);
} finally {
host.Close ();
}
}
[ServiceContract]
interface IBar
{
@@ -446,7 +469,14 @@ namespace MonoTests.System.ServiceModel
public class SingletonService
{
[OperationContract]
public void Process (string input)
public virtual void Process (string input)
{
}
}
public class ChildSingletonService : SingletonService
{
public override void Process (string input)
{
}
}