2010-03-26 Atsushi Enomoto <atsushi@ximian.com>
authorAtsushi Eno <atsushieno@gmail.com>
Fri, 26 Mar 2010 16:06:02 +0000 (16:06 -0000)
committerAtsushi Eno <atsushieno@gmail.com>
Fri, 26 Mar 2010 16:06:02 +0000 (16:06 -0000)
* FaultConverterTest.cs, MessageFaultTest.cs : add new and not-working
  tests.

svn path=/trunk/mcs/; revision=154286

mcs/class/System.ServiceModel/Test/System.ServiceModel.Channels/ChangeLog
mcs/class/System.ServiceModel/Test/System.ServiceModel.Channels/FaultConverterTest.cs
mcs/class/System.ServiceModel/Test/System.ServiceModel.Channels/MessageFaultTest.cs

index 15b366a1b1950a52724d771c3e22282bce549c5d..6f1fa6820550b18aef9b46352c27533a819394fa 100644 (file)
@@ -1,3 +1,8 @@
+2010-03-26  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * FaultConverterTest.cs, MessageFaultTest.cs : add new and not-working
+         tests.
+
 2010-03-26  Atsushi Enomoto  <atsushi@ximian.com>
 
        * MessageBufferTest.cs : add test for copy of IsFault value.
index 60587df22dcb44db3011677f36b815a517d6ba63..de994cf5f93d2db83caf42aff2db8521f6f5a67f 100644 (file)
@@ -38,7 +38,8 @@ namespace MonoTests.System.ServiceModel.Channels
        public class FaultConverterTest
        {
                static readonly FaultConverter s11 = FaultConverter.GetDefaultFaultConverter (MessageVersion.Soap11WSAddressing10);
-               static readonly FaultConverter s12 = FaultConverter.GetDefaultFaultConverter (MessageVersion.Default);
+               static readonly FaultConverter s12 = FaultConverter.GetDefaultFaultConverter (MessageVersion.Soap12WSAddressing10);
+               static readonly FaultConverter none = FaultConverter.GetDefaultFaultConverter (MessageVersion.None);
 
                XmlWriterSettings GetWriterSettings ()
                {
@@ -48,7 +49,8 @@ namespace MonoTests.System.ServiceModel.Channels
                }
 
                [Test]
-               public void TryCreateExceptionDefault ()
+               [Category ("NotWorking")]
+               public void TryCreateFaultMessageDefault ()
                {
                        Message msg;
                        Assert.IsFalse (s12.TryCreateFaultMessage (new Exception ("error happened"), out msg), "#1-1");
@@ -57,11 +59,66 @@ namespace MonoTests.System.ServiceModel.Channels
 
                        Assert.IsFalse (s12.TryCreateFaultMessage (new FaultException<string> ("fault happened."), out msg), "#1-3");
 
+                       Assert.IsTrue (s12.TryCreateFaultMessage (new ActionNotSupportedException (), out msg), "#1-4");
+                       Assert.IsTrue (msg.IsFault, "#1-5");
+                       Assert.AreEqual ("http://www.w3.org/2005/08/addressing/fault", msg.Headers.Action, "#1-6");
+                       var f = MessageFault.CreateFault (msg, 1000);
+                       Assert.AreEqual ("Sender", f.Code.Name, "#1-7");
+                       Assert.AreEqual ("http://www.w3.org/2003/05/soap-envelope", f.Code.Namespace, "#1-8");
+                       Assert.AreEqual ("ActionNotSupported", f.Code.SubCode.Name, "#1-9");
+                       Assert.AreEqual ("http://www.w3.org/2005/08/addressing", f.Code.SubCode.Namespace, "#1-10");
+
                        Assert.IsFalse (s11.TryCreateFaultMessage (new Exception ("error happened"), out msg), "#2-1");
 
                        Assert.IsFalse (s11.TryCreateFaultMessage (new FaultException ("fault happened", FaultCode.CreateSenderFaultCode (new FaultCode ("IAmBroken"))), out msg), "#2-2");
 
                        Assert.IsFalse (s11.TryCreateFaultMessage (new FaultException<string> ("fault happened."), out msg), "#2-3");
+
+                       Assert.IsTrue (s11.TryCreateFaultMessage (new ActionNotSupportedException (), out msg), "#2-4");
+                       Assert.IsTrue (msg.IsFault, "#2-5");
+                       Assert.AreEqual ("http://www.w3.org/2005/08/addressing/fault", msg.Headers.Action, "#2-6");
+                       f = MessageFault.CreateFault (msg, 1000);
+                       Assert.AreEqual ("ActionNotSupported", f.Code.Name, "#2-7");
+                       Assert.AreEqual ("http://www.w3.org/2005/08/addressing", f.Code.Namespace, "#2-8");
+
+                       Assert.IsFalse (none.TryCreateFaultMessage (new Exception ("error happened"), out msg), "#3-1");
+
+                       Assert.IsFalse (none.TryCreateFaultMessage (new FaultException ("fault happened", FaultCode.CreateSenderFaultCode (new FaultCode ("IAmBroken"))), out msg), "#3-2");
+
+                       Assert.IsFalse (none.TryCreateFaultMessage (new FaultException<string> ("fault happened."), out msg), "#3-3");
+
+                       Assert.IsFalse (none.TryCreateFaultMessage (new ActionNotSupportedException (), out msg), "#3-4");
+
+                       Assert.IsFalse (none.TryCreateFaultMessage (new EndpointNotFoundException (), out msg), "#3-5");
+               }
+
+               [Test]
+               [Category ("NotWorking")]
+               public void TryCreateExceptionDefault ()
+               {
+                       var xml = @"
+<s:Envelope xmlns:a='http://www.w3.org/2005/08/addressing' xmlns:s='http://schemas.xmlsoap.org/soap/envelope/'>
+  <s:Header>
+    <a:Action s:mustUnderstand='1'>http://www.w3.org/2005/08/addressing/fault</a:Action>
+  </s:Header>
+  <s:Body>
+    <s:Fault>
+      <faultcode>a:ActionNotSupported</faultcode>
+      <faultstring xml:lang='en-US'>some error</faultstring>
+    </s:Fault>
+  </s:Body>
+</s:Envelope>";
+                       var msg = Message.CreateMessage (XmlReader.Create (new StringReader (xml)), 0x1000, MessageVersion.Soap11WSAddressing10);
+                       var mf = MessageFault.CreateFault (msg, 1000);
+                       msg = Message.CreateMessage (XmlReader.Create (new StringReader (xml)), 0x1000, MessageVersion.Soap11WSAddressing10);
+                       Exception ex;
+                       Assert.IsTrue (s11.TryCreateException (msg, mf, out ex), "#1");
+
+                       // test buffered copy (which used to fail)
+                       msg = Message.CreateMessage (XmlReader.Create (new StringReader (xml)), 0x1000, MessageVersion.Soap11WSAddressing10);
+                       var mb = msg.CreateBufferedCopy (1000);
+                       mf = MessageFault.CreateFault (mb.CreateMessage (), 1000);
+                       Assert.IsTrue (s11.TryCreateException (mb.CreateMessage (), mf, out ex), "#2");
                }
        }
 }
index 791dee7f7d95c061d804a45fa0ab8d5911dfc954..99cd31490fb3ca258e3726903f38cad57f641413 100644 (file)
@@ -58,5 +58,28 @@ namespace MonoTests.System.ServiceModel.Channels
                        var msg = Message.CreateMessage (XmlReader.Create (new StreamReader ("Test/System.ServiceModel.Channels/soap-fault-incomplete4.xml")), 0x10000, MessageVersion.Default);
                        MessageFault.CreateFault (msg, 0x10000);
                }
+
+               [Test]
+               [Category ("NotWorking")]
+               public void CreateFaultFromMessage ()
+               {
+                       var xml = @"
+<s:Envelope xmlns:a='http://www.w3.org/2005/08/addressing' xmlns:s='http://schemas.xmlsoap.org/soap/envelope/'>
+  <s:Header>
+    <a:Action s:mustUnderstand='1'>http://www.w3.org/2005/08/addressing/fault</a:Action>
+  </s:Header>
+  <s:Body>
+    <s:Fault>
+      <faultcode>a:ActionNotSupported</faultcode>
+      <faultstring xml:lang='en-US'>some error</faultstring>
+    </s:Fault>
+  </s:Body>
+</s:Envelope>";
+                       var msg = Message.CreateMessage (XmlReader.Create (new StringReader (xml)), 0x1000, MessageVersion.Soap11WSAddressing10);
+                       MessageFault.CreateFault (msg, 1000);
+                       msg = Message.CreateMessage (XmlReader.Create (new StringReader (xml)), 0x1000, MessageVersion.Soap11WSAddressing10);
+                       var mb = msg.CreateBufferedCopy (1000);
+                       MessageFault.CreateFault (mb.CreateMessage (), 1000);
+               }
        }
 }