Author: atsushi
Date: 2008-02-12 10:09:54 -0500 (Tue, 12 Feb 2008)
New Revision: 95512

Added:
   
trunk/olive/class/System.ServiceModel.Web/System/UriTemplateEquivalenceComparer.cs
   trunk/olive/class/System.ServiceModel.Web/System/UriTemplateMatchException.cs
   trunk/olive/class/System.ServiceModel.Web/System/UriTemplateTable.cs
   
trunk/olive/class/System.ServiceModel.Web/Test/System.ServiceModel.Description/
   
trunk/olive/class/System.ServiceModel.Web/Test/System.ServiceModel.Description/ChangeLog
   
trunk/olive/class/System.ServiceModel.Web/Test/System.ServiceModel.Description/WebHttpBehaviorTest.cs
   trunk/olive/class/System.ServiceModel.Web/Test/System/
   trunk/olive/class/System.ServiceModel.Web/Test/System/ChangeLog
   trunk/olive/class/System.ServiceModel.Web/Test/System/UriTemplateTest.cs
Modified:
   
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Description/ChangeLog
   
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Description/WebHttpBehavior.cs
   
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Dispatcher/ChangeLog
   
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Dispatcher/WebHttpDispatchOperationSelector.cs
   trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Web.dll.sources
   
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Web_test.dll.sources
   trunk/olive/class/System.ServiceModel.Web/System/ChangeLog
   trunk/olive/class/System.ServiceModel.Web/System/UriTemplate.cs
Log:
2008-02-12  Atsushi Enomoto  <[EMAIL PROTECTED]>

        * UriTemplateTable.cs, UriTemplateEquivalenceComparer.cs : new stubs.
        * UriTemplateMatchException.cs : new.
        * UriTemplate.cs : implemented .ctor(), BindByName() and
          BindByPosition().

        * WebHttpDispatchOperationSelector.cs : stubbed members.

        * WebHttpBehavior.cs : some implementation (sorta wrong).

        * WebHttpBehaviorTest.cs : new test.

        * UriTemplateTest.cs : new. Test .ctor(), BindByName() and 
          BindByPosition().



Modified: trunk/olive/class/System.ServiceModel.Web/System/ChangeLog
===================================================================
--- trunk/olive/class/System.ServiceModel.Web/System/ChangeLog  2008-02-12 
15:08:05 UTC (rev 95511)
+++ trunk/olive/class/System.ServiceModel.Web/System/ChangeLog  2008-02-12 
15:09:54 UTC (rev 95512)
@@ -1,3 +1,6 @@
 2008-02-12  Atsushi Enomoto  <[EMAIL PROTECTED]>
 
-       * UriTemplate.cs, UriTemplateMatch.cs : new stubs.
+       * UriTemplateTable.cs, UriTemplateEquivalenceComparer.cs : new stubs.
+       * UriTemplateMatchException.cs : new.
+       * UriTemplate.cs : implemented .ctor(), BindByName() and
+         BindByPosition().

Modified: trunk/olive/class/System.ServiceModel.Web/System/UriTemplate.cs
===================================================================
--- trunk/olive/class/System.ServiceModel.Web/System/UriTemplate.cs     
2008-02-12 15:08:05 UTC (rev 95511)
+++ trunk/olive/class/System.ServiceModel.Web/System/UriTemplate.cs     
2008-02-12 15:09:54 UTC (rev 95512)
@@ -26,16 +26,149 @@
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 using System;
-using System.ServiceModel;
-using System.ServiceModel.Channels;
-using System.ServiceModel.Description;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Collections.Specialized;
+using System.Globalization;
+using System.Text;
 
 namespace System
 {
        public class UriTemplate
        {
+               static readonly ReadOnlyCollection<string> empty_strings = new 
ReadOnlyCollection<string> (new string [0]);
+
+               string template;
+               Uri uri;
+               ReadOnlyCollection<string> path, query;
+
                public UriTemplate (string template)
                {
+                       if (template == null)
+                               throw new ArgumentNullException ("template");
+                       this.template = template;
+
+                       int q = template.IndexOf ('?');
+                       path = ParseTemplate (template, 0, q >= 0 ? q : 
template.Length);
+                       if (q >= 0)
+                               query = ParseTemplate (template, q, 
template.Length);
+                       else
+                               query = empty_strings;
                }
+
+               public ReadOnlyCollection<string> PathSegmentVariableNames {
+                       get { return path; }
+               }
+
+               public ReadOnlyCollection<string> QueryValueVariableNames {
+                       get { return query; }
+               }
+
+               public Uri BindByName (Uri baseAddress, NameValueCollection 
parameters)
+               {
+                       CheckBaseAddress (baseAddress);
+
+                       int src = 0;
+                       StringBuilder sb = new StringBuilder (template.Length);
+                       BindByName (ref src, sb, path, parameters);
+                       BindByName (ref src, sb, query, parameters);
+                       sb.Append (template.Substring (src));
+                       return new Uri (baseAddress.ToString () + sb.ToString 
());
+               }
+
+               void BindByName (ref int src, StringBuilder sb, 
ReadOnlyCollection<string> names, NameValueCollection parameters)
+               {
+                       foreach (string name in names) {
+                               int s = template.IndexOf ('{', src);
+                               int e = template.IndexOf ('}', s + 1);
+                               sb.Append (template.Substring (src, s - src));
+                               string value = parameters [name];
+                               if (value == null)
+                                       throw new FormatException 
(String.Format ("The argument name value collection does not contain value for 
'{0}'", name));
+                               sb.Append (value);
+                               src = e + 1;
+                       }
+               }
+
+               public Uri BindByPosition (Uri baseAddress, params string [] 
values)
+               {
+                       CheckBaseAddress (baseAddress);
+
+                       if (values.Length != path.Count + query.Count)
+                               throw new FormatException (String.Format 
("Template '{0}' contains {1} parameters but the argument values to bind are 
{2}", template, path.Count + query.Count, values.Length));
+
+                       int src = 0, index = 0;
+                       StringBuilder sb = new StringBuilder (template.Length);
+                       BindByPosition (ref src, sb, path, values, ref index);
+                       BindByPosition (ref src, sb, query, values, ref index);
+                       sb.Append (template.Substring (src));
+                       return new Uri (baseAddress.ToString () + sb.ToString 
());
+               }
+
+               void BindByPosition (ref int src, StringBuilder sb, 
ReadOnlyCollection<string> names, string [] values, ref int index)
+               {
+                       foreach (string name in names) {
+                               int s = template.IndexOf ('{', src);
+                               int e = template.IndexOf ('}', s + 1);
+                               sb.Append (template.Substring (src, s - src));
+                               string value = values [index++];
+                               if (value == null)
+                                       throw new FormatException 
(String.Format ("The argument value collection contains null at {0}", index - 
1));
+                               sb.Append (value);
+                               src = e + 1;
+                       }
+               }
+
+               [MonoTODO]
+               public bool IsEquivalentTo (UriTemplate other)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               public UriTemplateMatch Match (Uri baseAddress, Uri candidate)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public override string ToString ()
+               {
+                       return template;
+               }
+
+               void CheckBaseAddress (Uri baseAddress)
+               {
+                       if (baseAddress == null)
+                               throw new ArgumentNullException ("baseAddress");
+                       if (!baseAddress.IsAbsoluteUri)
+                       throw new ArgumentException ("baseAddress must be an 
absolute URI.");
+                       if (baseAddress.Scheme == Uri.UriSchemeHttp ||
+                           baseAddress.Scheme == Uri.UriSchemeHttps)
+                               return;
+                       throw new ArgumentException ("baseAddress scheme must 
be either http or https.");
+               }
+
+               ReadOnlyCollection<string> ParseTemplate (string template, int 
index, int end)
+               {
+                       List<string> list = null;
+                       for (int i = index; i <= end; ) {
+                               i = template.IndexOf ('{', i);
+                               if (i < 0 || i > end)
+                                       break;
+                               int e = template.IndexOf ('}', i + 1);
+                               if (e < 0 || i > end)
+                                       break;
+                               if (list == null)
+                                       list = new List<string> ();
+                               i++;
+                               string name = template.Substring (i, e - i);
+                               string uname = name.ToUpper 
(CultureInfo.InvariantCulture);
+                               if (list.Contains (uname) || (path != null && 
path.Contains (uname)))
+                                       throw new InvalidOperationException 
(String.Format ("The URI template string contains duplicate template item 
{{'{0}'}}", name));
+                               list.Add (uname);
+                               i = e + 1;
+                       }
+                       return list != null ? new ReadOnlyCollection<string> 
(list) : empty_strings;
+               }
        }
 }

Added: 
trunk/olive/class/System.ServiceModel.Web/System/UriTemplateEquivalenceComparer.cs
===================================================================
--- 
trunk/olive/class/System.ServiceModel.Web/System/UriTemplateEquivalenceComparer.cs
  2008-02-12 15:08:05 UTC (rev 95511)
+++ 
trunk/olive/class/System.ServiceModel.Web/System/UriTemplateEquivalenceComparer.cs
  2008-02-12 15:09:54 UTC (rev 95512)
@@ -0,0 +1,51 @@
+//
+// UriTemplateEquivalenceComparer.cs
+//
+// Author:
+//     Atsushi Enomoto  <[EMAIL PROTECTED]>
+//
+// Copyright (C) 2008 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;
+
+namespace System
+{
+       public class UriTemplateEquivalenceComparer : 
IEqualityComparer<UriTemplate>
+       {
+               public UriTemplateEquivalenceComparer ()
+               {
+               }
+
+               [MonoTODO]
+               public bool Equals (UriTemplate x, UriTemplate y)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               public int GetHashCode (UriTemplate obj)
+               {
+                       throw new NotImplementedException ();
+               }
+       }
+}


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

Added: 
trunk/olive/class/System.ServiceModel.Web/System/UriTemplateMatchException.cs
===================================================================
--- 
trunk/olive/class/System.ServiceModel.Web/System/UriTemplateMatchException.cs   
    2008-02-12 15:08:05 UTC (rev 95511)
+++ 
trunk/olive/class/System.ServiceModel.Web/System/UriTemplateMatchException.cs   
    2008-02-12 15:09:54 UTC (rev 95512)
@@ -0,0 +1,43 @@
+//
+// UriTemplateMatchException.cs
+//
+// Author: Atsushi Enomoto <[EMAIL PROTECTED]>
+//
+// Copyright (C) 2008 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.ObjectModel;
+using System.Runtime.Serialization;
+
+namespace System
+{
+       [Serializable]
+       public class UriTemplateMatchException : SystemException
+       {
+               public UriTemplateMatchException () : base () {}
+               public UriTemplateMatchException (string msg) : base (msg) {}
+               public UriTemplateMatchException (string msg, Exception inner) 
: base (msg, inner) {}
+               protected UriTemplateMatchException (SerializationInfo info, 
StreamingContext context) :
+                       base (info, context) {}
+       }
+}


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

Added: trunk/olive/class/System.ServiceModel.Web/System/UriTemplateTable.cs
===================================================================
--- trunk/olive/class/System.ServiceModel.Web/System/UriTemplateTable.cs        
2008-02-12 15:08:05 UTC (rev 95511)
+++ trunk/olive/class/System.ServiceModel.Web/System/UriTemplateTable.cs        
2008-02-12 15:09:54 UTC (rev 95512)
@@ -0,0 +1,105 @@
+//
+// UriTemplateTable.cs
+//
+// Author:
+//     Atsushi Enomoto  <[EMAIL PROTECTED]>
+//
+// Copyright (C) 2008 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.Collections.ObjectModel;
+using System.Collections.Specialized;
+
+using Pair = System.Collections.Generic.KeyValuePair<System.UriTemplate, 
object>;
+
+namespace System
+{
+       public class UriTemplateTable
+       {
+               public UriTemplateTable ()
+               {
+               }
+
+               public UriTemplateTable (Uri baseAddress)
+               {
+                       BaseAddress = baseAddress;
+               }
+
+               public UriTemplateTable (IEnumerable<Pair> keyValuePairs)
+               {
+                       IList<Pair> l = keyValuePairs as IList<Pair>;
+                       if (l == null)
+                               l = new List<Pair> (keyValuePairs);
+               }
+
+               public UriTemplateTable (Uri baseAddress, IEnumerable<Pair> 
keyValuePairs)
+                       : this (keyValuePairs)
+               {
+                       BaseAddress = baseAddress;
+               }
+
+               void CheckReadOnly ()
+               {
+                       if (is_readonly)
+                               throw new InvalidOperationException ("This 
UriTemplateTable is read-only");
+               }
+
+               bool is_readonly;
+               Uri base_address;
+               IList<Pair> key_value_pairs;
+
+               public Uri BaseAddress {
+                       get { return base_address; }
+                       set {
+                               CheckReadOnly ();
+                               base_address = value;
+                       }
+               }
+
+               public bool IsReadOnly {
+                       get { return is_readonly; }
+               }
+
+               public IList<Pair> KeyValuePairs {
+                       get { return key_value_pairs; }
+               }
+
+               [MonoTODO]
+               public void MakeReadOnly (bool 
allowDuplicateEquivalentUriTemplates)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               public Collection<UriTemplateMatch> Match (Uri uri)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               public UriTemplateMatch MatchSingle (Uri uri)
+               {
+                       throw new NotImplementedException ();
+               }
+       }
+}


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

Modified: 
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Description/ChangeLog
===================================================================
--- 
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Description/ChangeLog
 2008-02-12 15:08:05 UTC (rev 95511)
+++ 
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Description/ChangeLog
 2008-02-12 15:09:54 UTC (rev 95512)
@@ -1,3 +1,7 @@
+2008-02-12  Atsushi Enomoto  <[EMAIL PROTECTED]>
+
+       * WebHttpBehavior.cs : some implementation (sorta wrong).
+
 2008-02-07  Atsushi Enomoto  <[EMAIL PROTECTED]>
 
        * WebHttpBehavior.cs : stub.

Modified: 
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Description/WebHttpBehavior.cs
===================================================================
--- 
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Description/WebHttpBehavior.cs
        2008-02-12 15:08:05 UTC (rev 95511)
+++ 
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Description/WebHttpBehavior.cs
        2008-02-12 15:09:54 UTC (rev 95512)
@@ -29,6 +29,7 @@
 using System.ServiceModel;
 using System.ServiceModel.Channels;
 using System.ServiceModel.Dispatcher;
+using System.ServiceModel.Web;
 
 namespace System.ServiceModel.Description
 {
@@ -38,9 +39,30 @@
                {
                }
 
+               WebMessageFormat default_request_format, 
default_response_format;
+               WebMessageBodyStyle default_body_style;
+
                [MonoTODO]
+               public virtual WebMessageBodyStyle DefaultBodyStyle {
+                       get { return default_body_style; }
+                       set { default_body_style = value; }
+               }
+
+               [MonoTODO]
+               public virtual WebMessageFormat DefaultOutgoingRequestFormat {
+                       get { return default_request_format; }
+                       set { default_request_format = value; }
+               }
+
+               [MonoTODO]
+               public virtual WebMessageFormat DefaultOutgoingResponseFormat {
+                       get { return default_response_format; }
+                       set { default_response_format = value; }
+               }
+
                public virtual void AddBindingParameters (ServiceEndpoint 
endpoint, BindingParameterCollection bindingParameters)
                {
+                       // nothing
                }
 
                [MonoTODO]
@@ -56,17 +78,27 @@
                [MonoTODO]
                public virtual void ApplyClientBehavior (ServiceEndpoint 
endpoint, ClientRuntime clientRuntime)
                {
+                       foreach (ClientOperation oper in 
clientRuntime.Operations) {
+                               // 
GetClientRequestFormatter/GetClientReplyFormatter
+                               oper.Formatter = GetRequestClientFormatter 
(endpoint.Contract.Operations.Find (oper.Name), endpoint);
+                               oper.Formatter = GetReplyClientFormatter 
(endpoint.Contract.Operations.Find (oper.Name), endpoint);
+                       }
                }
 
-               [MonoTODO]
                public virtual void ApplyDispatchBehavior (ServiceEndpoint 
endpoint, EndpointDispatcher endpointDispatcher)
                {
+                       endpointDispatcher.DispatchRuntime.OperationSelector = 
GetOperationSelector (endpoint);
+
+                       foreach (DispatchOperation oper in 
endpointDispatcher.DispatchRuntime.Operations) {
+                               // 
GetClientRequestFormatter/GetClientReplyFormatter
+                               oper.Formatter = GetRequestDispatchFormatter 
(endpoint.Contract.Operations.Find (oper.Name), endpoint);
+                               oper.Formatter = GetReplyDispatchFormatter 
(endpoint.Contract.Operations.Find (oper.Name), endpoint);
+                       }
                }
 
-               [MonoTODO]
                protected virtual WebHttpDispatchOperationSelector 
GetOperationSelector (ServiceEndpoint endpoint)
                {
-                       throw new NotImplementedException ();
+                       return new WebHttpDispatchOperationSelector (endpoint);
                }
 
                [MonoTODO]

Modified: 
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Dispatcher/ChangeLog
===================================================================
--- 
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Dispatcher/ChangeLog
  2008-02-12 15:08:05 UTC (rev 95511)
+++ 
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Dispatcher/ChangeLog
  2008-02-12 15:09:54 UTC (rev 95512)
@@ -1,3 +1,7 @@
+2008-02-12  Atsushi Enomoto  <[EMAIL PROTECTED]>
+
+       * WebHttpDispatchOperationSelector.cs : stubbed members.
+
 2008-02-07  Atsushi Enomoto  <[EMAIL PROTECTED]>
 
        * JsonQueryStringConverter.cs, QueryStringConverter.cs,

Modified: 
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Dispatcher/WebHttpDispatchOperationSelector.cs
===================================================================
--- 
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Dispatcher/WebHttpDispatchOperationSelector.cs
        2008-02-12 15:08:05 UTC (rev 95511)
+++ 
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Dispatcher/WebHttpDispatchOperationSelector.cs
        2008-02-12 15:09:54 UTC (rev 95512)
@@ -27,11 +27,34 @@
 //
 using System;
 using System.ServiceModel;
+using System.ServiceModel.Channels;
 using System.ServiceModel.Description;
 
 namespace System.ServiceModel.Dispatcher
 {
-       public class WebHttpDispatchOperationSelector
+       public class WebHttpDispatchOperationSelector : 
IDispatchOperationSelector
        {
+               public const string HttpOperationSelectorUriMatchedPropertyName 
= "UriMatched";
+
+               protected WebHttpDispatchOperationSelector ()
+               {
+               }
+
+               public WebHttpDispatchOperationSelector (ServiceEndpoint 
endpoint)
+               {
+               }
+
+               [MonoTODO]
+               public string SelectOperation (ref Message message)
+               {
+                       bool dummy;
+                       return SelectOperation (ref message, out dummy);
+               }
+
+               [MonoTODO]
+               protected virtual string SelectOperation (ref Message message, 
out bool uriMatched)
+               {
+                       throw new NotImplementedException ();
+               }
        }
 }

Modified: 
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Web.dll.sources
===================================================================
--- 
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Web.dll.sources   
    2008-02-12 15:08:05 UTC (rev 95511)
+++ 
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Web.dll.sources   
    2008-02-12 15:09:54 UTC (rev 95512)
@@ -61,4 +61,7 @@
 System.ServiceModel/WebHttpSecurity.cs
 System.ServiceModel/WebHttpSecurityMode.cs
 System/UriTemplate.cs
+System/UriTemplateEquivalenceComparer.cs
 System/UriTemplateMatch.cs
+System/UriTemplateMatchException.cs
+System/UriTemplateTable.cs

Modified: 
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Web_test.dll.sources
===================================================================
--- 
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Web_test.dll.sources
  2008-02-12 15:08:05 UTC (rev 95511)
+++ 
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Web_test.dll.sources
  2008-02-12 15:09:54 UTC (rev 95512)
@@ -3,6 +3,7 @@
 System.Runtime.Serialization.Json/JsonWriterTest.cs
 System.ServiceModel.Channels/WebBodyFormatMessagePropertyTest.cs
 System.ServiceModel.Channels/WebMessageEncodingBindingElementTest.cs
+System.ServiceModel.Description/WebHttpBehaviorTest.cs
 System.ServiceModel.Syndication/Atom10FeedFormatterTest.cs
 System.ServiceModel.Syndication/Atom10ItemFormatterTest.cs
 System.ServiceModel.Syndication/Rss20FeedFormatterTest.cs
@@ -15,3 +16,4 @@
 System.ServiceModel.Syndication/UrlSyndicationContentTest.cs
 System.ServiceModel.Syndication/XmlSyndicationContentTest.cs
 System.ServiceModel/WebHttpBindingTest.cs
+System/UriTemplateTest.cs

Added: trunk/olive/class/System.ServiceModel.Web/Test/System/ChangeLog
===================================================================
--- trunk/olive/class/System.ServiceModel.Web/Test/System/ChangeLog     
2008-02-12 15:08:05 UTC (rev 95511)
+++ trunk/olive/class/System.ServiceModel.Web/Test/System/ChangeLog     
2008-02-12 15:09:54 UTC (rev 95512)
@@ -0,0 +1,4 @@
+2008-02-12  Atsushi Enomoto  <[EMAIL PROTECTED]>
+
+       * UriTemplateTest.cs : new. Test .ctor(), BindByName() and 
+         BindByPosition().

Added: trunk/olive/class/System.ServiceModel.Web/Test/System/UriTemplateTest.cs
===================================================================
--- trunk/olive/class/System.ServiceModel.Web/Test/System/UriTemplateTest.cs    
2008-02-12 15:08:05 UTC (rev 95511)
+++ trunk/olive/class/System.ServiceModel.Web/Test/System/UriTemplateTest.cs    
2008-02-12 15:09:54 UTC (rev 95512)
@@ -0,0 +1,209 @@
+//
+// UriTemplate.cs
+//
+// Author:
+//     Atsushi Enomoto  <[EMAIL PROTECTED]>
+//
+// Copyright (C) 2008 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.ObjectModel;
+using System.Collections.Specialized;
+using NUnit.Framework;
+
+namespace MonoTests.System
+{
+       [TestFixture]
+       public class UriTemplateTest
+       {
+               [Test]
+               [ExpectedException (typeof (ArgumentNullException))]
+               public void ConstructorNull ()
+               {
+                       new UriTemplate (null);
+               }
+
+               [Test]
+               public void ConstructorEmpty ()
+               {
+                       // it does not raise an error at this state.
+                       new UriTemplate (String.Empty);
+               }
+
+               [Test]
+               public void ConstructorBrokenTemplate ()
+               {
+                       // it does not raise an error at this state.
+                       new UriTemplate ("{");
+               }
+
+               [Test]
+               public void ToString ()
+               {
+                       Assert.AreEqual ("urn:foo", new UriTemplate 
("urn:foo").ToString (), "#1");
+                       Assert.AreEqual ("{", new UriTemplate ("{").ToString 
(), "#2");
+               }
+
+               [Test]
+               public void Variables ()
+               {
+                       var t = new UriTemplate ("urn:foo");
+                       Assert.AreEqual (0, t.PathSegmentVariableNames.Count, 
"#1a");
+                       Assert.AreEqual (0, t.QueryValueVariableNames.Count, 
"#1b");
+                       t = new UriTemplate ("http://localhost:8080/";);
+                       Assert.AreEqual (0, t.PathSegmentVariableNames.Count, 
"#2a");
+                       Assert.AreEqual (0, t.QueryValueVariableNames.Count, 
"#2b");
+                       t = new UriTemplate ("http://localhost:8080/foo/";);
+                       Assert.AreEqual (0, t.PathSegmentVariableNames.Count, 
"#3a");
+                       Assert.AreEqual (0, t.QueryValueVariableNames.Count, 
"#3b");
+                       t = new UriTemplate ("http://localhost:8080/{foo}";);
+                       Assert.AreEqual (1, t.PathSegmentVariableNames.Count, 
"#4a");
+                       Assert.AreEqual ("FOO", t.PathSegmentVariableNames [0], 
"#4b");
+                       Assert.AreEqual (0, t.QueryValueVariableNames.Count, 
"#4c");
+                       t = new UriTemplate ("http://localhost:8080/{foo}/{";);
+                       Assert.AreEqual (1, t.PathSegmentVariableNames.Count, 
"#5a");
+                       Assert.AreEqual ("FOO", t.PathSegmentVariableNames [0], 
"#5b");
+                       Assert.AreEqual (0, t.QueryValueVariableNames.Count, 
"#5c");
+                       t = new UriTemplate 
("http://localhost:8080/hoge?test={foo}&test2={bar}";);
+                       Assert.AreEqual (0, t.PathSegmentVariableNames.Count, 
"#6a");
+                       Assert.AreEqual (2, t.QueryValueVariableNames.Count, 
"#6b");
+                       Assert.AreEqual ("FOO", t.QueryValueVariableNames [0], 
"#6c");
+                       Assert.AreEqual ("BAR", t.QueryValueVariableNames [1], 
"#6d");
+               }
+
+               [Test]
+               [ExpectedException (typeof (InvalidOperationException))]
+               public void DuplicateNameInTemplate ()
+               {
+                       // one name to two places to match
+                       new UriTemplate 
("http://localhost:8080/hoge?test={foo}&test2={foo}";);
+               }
+
+               [Test]
+               [ExpectedException (typeof (InvalidOperationException))]
+               public void DuplicateNameInTemplate2 ()
+               {
+                       // one name to two places to match
+                       new UriTemplate 
("http://localhost:8080/hoge/{foo}?test={foo}";);
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentNullException))]
+               public void BindByNameNullBaseAddress ()
+               {
+                       var t = new UriTemplate ("http://localhost:8080/";);
+                       t.BindByName (null, new NameValueCollection ());
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentException))]
+               public void BindByNameRelativeBaseAddress ()
+               {
+                       var t = new UriTemplate ("http://localhost:8080/";);
+                       t.BindByName (new Uri ("", UriKind.Relative), new 
NameValueCollection ());
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentException))]
+               public void BindByNameFileUriBaseAddress ()
+               {
+                       var t = new UriTemplate ("http://localhost:8080/";);
+                       t.BindByName (new Uri ("file:///"), new 
NameValueCollection ());
+               }
+
+               [Test] // it is allowed.
+               public void BindByNameFileExtraNames ()
+               {
+                       var t = new UriTemplate ("http://localhost:8080/";);
+                       var n = new NameValueCollection ();
+                       n.Add ("name", "value");
+                       t.BindByName (new Uri ("http://localhost/";), n);
+               }
+
+               [Test]
+               [ExpectedException (typeof (FormatException))]
+               public void BindByNameFileMissingName ()
+               {
+                       var t = new UriTemplate ("/{foo}/");
+                       t.BindByName (new Uri ("http://localhost/";), new 
NameValueCollection ());
+               }
+
+               [Test]
+               public void BindByName ()
+               {
+                       var t = new UriTemplate ("/{foo}/{bar}/");
+                       var n = new NameValueCollection ();
+                       n.Add ("Bar", "value1"); // case insensitive
+                       n.Add ("FOO", "value2"); // case insensitive
+                       var u = t.BindByName (new Uri ("http://localhost/";), n);
+                       Assert.AreEqual ("http://localhost/value2/value1/";, 
u.ToString ());
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentNullException))]
+               public void BindByPositionNullBaseAddress ()
+               {
+                       var t = new UriTemplate ("http://localhost:8080/";);
+                       t.BindByPosition (null);
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentException))]
+               public void BindByPositionRelativeBaseAddress ()
+               {
+                       var t = new UriTemplate ("http://localhost:8080/";);
+                       t.BindByPosition (new Uri ("", UriKind.Relative));
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentException))]
+               public void BindByPositionFileUriBaseAddress ()
+               {
+                       var t = new UriTemplate ("http://localhost:8080/";);
+                       t.BindByPosition (new Uri ("file:///"));
+               }
+
+               [Test] // it is NOT allowed (unlike BindByName)
+               [ExpectedException (typeof (FormatException))]
+               public void BindByPositionFileExtraValues ()
+               {
+                       var t = new UriTemplate ("http://localhost:8080/";);
+                       t.BindByPosition (new Uri ("http://localhost/";), 
"value");
+               }
+
+               [Test]
+               [ExpectedException (typeof (FormatException))]
+               public void BindByPositionFileMissingValues ()
+               {
+                       var t = new UriTemplate ("/{foo}/");
+                       t.BindByPosition (new Uri ("http://localhost/";));
+               }
+
+               [Test]
+               public void BindByPosition ()
+               {
+                       var t = new UriTemplate ("/{foo}/{bar}/");
+                       var u = t.BindByPosition (new Uri 
("http://localhost/";), "value1", "value2");
+                       Assert.AreEqual ("http://localhost/value1/value2/";, 
u.ToString ());
+               }
+       }
+}


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

Added: 
trunk/olive/class/System.ServiceModel.Web/Test/System.ServiceModel.Description/ChangeLog
===================================================================
--- 
trunk/olive/class/System.ServiceModel.Web/Test/System.ServiceModel.Description/ChangeLog
    2008-02-12 15:08:05 UTC (rev 95511)
+++ 
trunk/olive/class/System.ServiceModel.Web/Test/System.ServiceModel.Description/ChangeLog
    2008-02-12 15:09:54 UTC (rev 95512)
@@ -0,0 +1,3 @@
+2008-02-12  Atsushi Enomoto  <[EMAIL PROTECTED]>
+
+       * WebHttpBehaviorTest.cs : new test.

Added: 
trunk/olive/class/System.ServiceModel.Web/Test/System.ServiceModel.Description/WebHttpBehaviorTest.cs
===================================================================
--- 
trunk/olive/class/System.ServiceModel.Web/Test/System.ServiceModel.Description/WebHttpBehaviorTest.cs
       2008-02-12 15:08:05 UTC (rev 95511)
+++ 
trunk/olive/class/System.ServiceModel.Web/Test/System.ServiceModel.Description/WebHttpBehaviorTest.cs
       2008-02-12 15:09:54 UTC (rev 95512)
@@ -0,0 +1,33 @@
+using System;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.Text;
+using NUnit.Framework;
+
+namespace MonoTests.System.ServiceModel.Description
+{
+       [TestFixture]
+       public class WebHttpBehaviorTest
+       {
+               [Test]
+               public void AddBiningParameters ()
+               {
+                       var se = new ServiceEndpoint (
+                               ContractDescription.GetContract (typeof 
(IMyService)),
+                               new WebHttpBinding (),
+                               new EndpointAddress ("http://localhost:37564";));
+                       var b = new WebHttpBehavior ();
+                       var pl = new BindingParameterCollection ();
+                       b.AddBindingParameters (se, pl);
+                       Assert.AreEqual (0, pl.Count, "#1");
+               }
+
+               [ServiceContract]
+               public interface IMyService
+               {
+                       [OperationContract]
+                       string Echo (string input);
+               }
+       }
+}


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

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

Reply via email to