Author: atsushi
Date: 2006-12-04 04:57:48 -0500 (Mon, 04 Dec 2006)
New Revision: 68935

Added:
   
trunk/olive/class/System.ServiceModel/System.ServiceModel.Channels/FaultConverter.cs
   
trunk/olive/class/System.ServiceModel/Test/System.ServiceModel.Channels/FaultConverterTest.cs
Modified:
   trunk/olive/class/System.ServiceModel/
   trunk/olive/class/System.ServiceModel/System.ServiceModel.Channels/ChangeLog
   trunk/olive/class/System.ServiceModel/System.ServiceModel.dll.sources
   trunk/olive/class/System.ServiceModel/System.ServiceModel_test.dll.sources
   
trunk/olive/class/System.ServiceModel/Test/System.ServiceModel.Channels/ChangeLog
Log:
2006-12-04  Atsushi Enomoto  <[EMAIL PROTECTED]>

        * FaultConverter.cs : new file, not used yet though.

        * FaultConverterTest.cs : new test.




Property changes on: trunk/olive/class/System.ServiceModel
___________________________________________________________________
Name: svn:ignore
   + TestResult-net_3_0.log
TestResult-net_3_0.xml
TestResult-ondotnet-net_3_0.log
TestResult-ondotnet-net_3_0.xml
System.ServiceModel_test_net_3_0.dll
System.ServiceModel_test_net_3_0.dll.mdb


Modified: 
trunk/olive/class/System.ServiceModel/System.ServiceModel.Channels/ChangeLog
===================================================================
--- 
trunk/olive/class/System.ServiceModel/System.ServiceModel.Channels/ChangeLog    
    2006-12-04 09:11:07 UTC (rev 68934)
+++ 
trunk/olive/class/System.ServiceModel/System.ServiceModel.Channels/ChangeLog    
    2006-12-04 09:57:48 UTC (rev 68935)
@@ -1,3 +1,7 @@
+2006-12-04  Atsushi Enomoto  <[EMAIL PROTECTED]>
+
+       * FaultConverter.cs : new file, not used yet though.
+
 2006-10-21  Atsushi Enomoto  <[EMAIL PROTECTED]>
 
        * SvcHttpHandler.cs : set GET URL to ServiceMetadataBehavior.

Added: 
trunk/olive/class/System.ServiceModel/System.ServiceModel.Channels/FaultConverter.cs
===================================================================
--- 
trunk/olive/class/System.ServiceModel/System.ServiceModel.Channels/FaultConverter.cs
        2006-12-04 09:11:07 UTC (rev 68934)
+++ 
trunk/olive/class/System.ServiceModel/System.ServiceModel.Channels/FaultConverter.cs
        2006-12-04 09:57:48 UTC (rev 68935)
@@ -0,0 +1,110 @@
+//
+// FaultConverter.cs
+//
+// Author:
+//     Atsushi Enomoto <[EMAIL PROTECTED]>
+//
+// Copyright (C) 2006 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 System.Collections.Generic;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+
+namespace System.ServiceModel.Channels
+{
+       [MonoTODO]
+       public abstract class FaultConverter
+       {
+               static FaultConverter soap12 = new Soap12FaultConverter ();
+               static FaultConverter soap11 = new Soap11FaultConverter ();
+
+               public static FaultConverter GetDefaultFaultConverter 
(MessageVersion version)
+               {
+                       if (version == null)
+                               throw new ArgumentNullException ("version");
+                       return version.Envelope == EnvelopeVersion.Soap11 ? 
soap11 : soap12;
+               }
+
+               protected FaultConverter ()
+               {
+               }
+
+               protected abstract bool OnTryCreateException (
+                       Message message, MessageFault fault, out Exception 
error);
+
+               protected abstract bool OnTryCreateFaultMessage (
+                       Exception error, out Message message);
+
+               public bool TryCreateException (Message message, MessageFault 
fault, out Exception error)
+               {
+                       return OnTryCreateException (message, fault, out error);
+               }
+
+               public bool TryCreateFaultMessage (Exception error, out Message 
message)
+               {
+                       return OnTryCreateFaultMessage (error, out message);
+               }
+
+               class Soap12FaultConverter : FaultConverter
+               {
+                       public Soap12FaultConverter ()
+                       {
+                       }
+
+                       protected override bool OnTryCreateException (
+                               Message message, MessageFault fault, out 
Exception error)
+                       {
+                               error = null;
+                               return false;
+                       }
+
+                       protected override bool OnTryCreateFaultMessage (
+                               Exception error, out Message message)
+                       {
+                               message = null;
+                               return false;
+                       }
+               }
+
+               class Soap11FaultConverter : FaultConverter
+               {
+                       public Soap11FaultConverter ()
+                       {
+                       }
+
+                       protected override bool OnTryCreateException (
+                               Message message, MessageFault fault, out 
Exception error)
+                       {
+                               error = null;
+                               return false;
+                       }
+
+                       protected override bool OnTryCreateFaultMessage (
+                               Exception error, out Message message)
+                       {
+                               message = null;
+                               return false;
+                       }
+               }
+       }
+}


Property changes on: 
trunk/olive/class/System.ServiceModel/System.ServiceModel.Channels/FaultConverter.cs
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: trunk/olive/class/System.ServiceModel/System.ServiceModel.dll.sources
===================================================================
--- trunk/olive/class/System.ServiceModel/System.ServiceModel.dll.sources       
2006-12-04 09:11:07 UTC (rev 68934)
+++ trunk/olive/class/System.ServiceModel/System.ServiceModel.dll.sources       
2006-12-04 09:57:48 UTC (rev 68935)
@@ -92,6 +92,7 @@
 System.ServiceModel.Channels/DeliveryFailure.cs
 System.ServiceModel.Channels/DeliveryStatus.cs
 System.ServiceModel.Channels/DirectionalAction.cs
+System.ServiceModel.Channels/FaultConverter.cs
 System.ServiceModel.Channels/HostedTransportConfiguration.cs
 System.ServiceModel.Channels/HtmlizedException.cs
 System.ServiceModel.Channels/HttpChannelFactory.cs

Modified: 
trunk/olive/class/System.ServiceModel/System.ServiceModel_test.dll.sources
===================================================================
--- trunk/olive/class/System.ServiceModel/System.ServiceModel_test.dll.sources  
2006-12-04 09:11:07 UTC (rev 68934)
+++ trunk/olive/class/System.ServiceModel/System.ServiceModel_test.dll.sources  
2006-12-04 09:57:48 UTC (rev 68935)
@@ -9,6 +9,7 @@
 System.ServiceModel.Channels/DebugBindingElement.cs
 System.ServiceModel.Channels/EmptyFaultExceptionTest.cs
 System.ServiceModel.Channels/EnvelopeVersionTest.cs
+System.ServiceModel.Channels/FaultConverterTest.cs
 System.ServiceModel.Channels/FaultExceptionTest.cs
 System.ServiceModel.Channels/HandlerBodyWriter.cs
 System.ServiceModel.Channels/HandlerTransportBindingElement.cs

Modified: 
trunk/olive/class/System.ServiceModel/Test/System.ServiceModel.Channels/ChangeLog
===================================================================
--- 
trunk/olive/class/System.ServiceModel/Test/System.ServiceModel.Channels/ChangeLog
   2006-12-04 09:11:07 UTC (rev 68934)
+++ 
trunk/olive/class/System.ServiceModel/Test/System.ServiceModel.Channels/ChangeLog
   2006-12-04 09:57:48 UTC (rev 68935)
@@ -1,3 +1,7 @@
+2006-12-04  Atsushi Enomoto  <[EMAIL PROTECTED]>
+
+       * FaultConverterTest.cs : new test.
+
 2006-10-13  Ankit Jain  <[EMAIL PROTECTED]>
 
        * MessageVersionTest.cs : Add test for MessageVersion.None

Added: 
trunk/olive/class/System.ServiceModel/Test/System.ServiceModel.Channels/FaultConverterTest.cs
===================================================================
--- 
trunk/olive/class/System.ServiceModel/Test/System.ServiceModel.Channels/FaultConverterTest.cs
       2006-12-04 09:11:07 UTC (rev 68934)
+++ 
trunk/olive/class/System.ServiceModel/Test/System.ServiceModel.Channels/FaultConverterTest.cs
       2006-12-04 09:57:48 UTC (rev 68935)
@@ -0,0 +1,67 @@
+//
+// FaultConverterTest.cs
+//
+// Author:
+//     Atsushi Enomoto <[EMAIL PROTECTED]>
+//
+// Copyright (C) 2006 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 System.IO;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.Xml;
+using NUnit.Framework;
+
+namespace MonoTests.System.ServiceModel.Channels
+{
+       [TestFixture]
+       public class FaultConverterTest
+       {
+               static readonly FaultConverter s11 = 
FaultConverter.GetDefaultFaultConverter (MessageVersion.Soap11WSAddressing10);
+               static readonly FaultConverter s12 = 
FaultConverter.GetDefaultFaultConverter (MessageVersion.Default);
+
+               XmlWriterSettings GetWriterSettings ()
+               {
+                       XmlWriterSettings s = new XmlWriterSettings ();
+                       s.OmitXmlDeclaration = true;
+                       return s;
+               }
+
+               [Test]
+               public void TryCreateExceptionDefault ()
+               {
+                       Message msg;
+                       Assert.IsFalse (s12.TryCreateFaultMessage (new 
Exception ("error happened"), out msg), "#1-1");
+
+                       Assert.IsFalse (s12.TryCreateFaultMessage (new 
FaultException ("fault happened", FaultCode.CreateSenderFaultCode (new 
FaultCode ("IAmBroken"))), out msg), "#1-2");
+
+                       Assert.IsFalse (s12.TryCreateFaultMessage (new 
FaultException<string> ("fault happened."), out msg), "#1-3");
+
+                       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");
+               }
+       }
+}


Property changes on: 
trunk/olive/class/System.ServiceModel/Test/System.ServiceModel.Channels/FaultConverterTest.cs
___________________________________________________________________
Name: svn:eol-style
   + native

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to