Add new MetadataSetTest and fix couple of minor issues.
authorAtsushi Eno <atsushi@ximian.com>
Tue, 10 May 2011 10:33:52 +0000 (19:33 +0900)
committerAtsushi Eno <atsushi@ximian.com>
Tue, 10 May 2011 10:33:52 +0000 (19:33 +0900)
mcs/class/System.ServiceModel/System.ServiceModel.Description/MetadataExchangeClient.cs
mcs/class/System.ServiceModel/System.ServiceModel.Description/MetadataSet.cs
mcs/class/System.ServiceModel/System.ServiceModel_test.dll.sources
mcs/class/System.ServiceModel/Test/System.ServiceModel.Description/MetadataSetTest.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/XmlFiles/one.xml [new file with mode: 0644]

index 74c70f1f9297d44c6b5026f1420ea063ca4105c4..7d652098c94da7ee6c2b3e6cace9b5cc9f676988 100644 (file)
@@ -98,6 +98,9 @@ namespace System.ServiceModel.Description
                [MonoTODO ("use dialect and identifier (but how?)")]
                protected internal virtual ChannelFactory<IMetadataExchange> GetChannelFactory (EndpointAddress metadataAddress, string dialect, string identifier)
                {
+                       if (metadataAddress == null)
+                               throw new ArgumentNullException ("metadataAddress");
+
                        var se = new ServiceEndpoint (ContractDescription.GetContract (typeof (IMetadataExchange)), CreateBinding (metadataAddress), metadataAddress);
                        if (SoapCredentials != null) {
                                se.Behaviors.RemoveAll<ClientCredentials> ();
index 32aed2331a34e3a27926ddc966197094e65dd25e..b55646f65acd969a46644418ca65c521972484f7 100644 (file)
@@ -71,6 +71,9 @@ namespace System.ServiceModel.Description
 
                void IXmlSerializable.ReadXml (XmlReader reader)
                {
+                       if (reader == null)
+                               throw new ArgumentNullException ("reader");
+
                        if (reader.NodeType != XmlNodeType.Element || reader.LocalName != "Metadata" || 
                                        reader.NamespaceURI != "http://schemas.xmlsoap.org/ws/2004/09/mex") 
                                throw new InvalidOperationException (String.Format ("Unexpected : <{0} ..", reader.LocalName));
@@ -88,11 +91,16 @@ namespace System.ServiceModel.Description
 
                void IXmlSerializable.WriteXml (XmlWriter writer)
                {
+                       if (writer == null)
+                               throw new ArgumentNullException ("writer");
+
                        throw new NotImplementedException ();
                }
 
                public static MetadataSet ReadFrom (XmlReader reader)
                {
+                       if (reader == null)
+                               throw new ArgumentNullException ("reader");
                        XmlSerializer xs = new XmlSerializer (typeof (MetadataSet));
                        MetadataSet ms = (MetadataSet) xs.Deserialize (reader);
 
@@ -101,6 +109,8 @@ namespace System.ServiceModel.Description
 
                public void WriteTo (XmlWriter writer)
                {
+                       if (writer == null)
+                               throw new ArgumentNullException ("writer");
                        writer.WriteStartElement ("Metadata", "http://schemas.xmlsoap.org/ws/2004/09/mex");
 
                        writer.WriteAttributeString ("xmlns", "xsd", "http://www.w3.org/2000/xmlns/", XmlSchema.Namespace);
index 1cd8470ef8eaa5ba11433a5a752ccf3888a49496..681ac1e3efdd5a2acf3df3675564180731a0499e 100644 (file)
@@ -110,6 +110,7 @@ System.ServiceModel.Description/ContractDescriptionTest.cs
 System.ServiceModel.Description/FaultDescriptionTest.cs
 System.ServiceModel.Description/MetadataExchangeBindingsTest.cs
 System.ServiceModel.Description/MetadataResolverTest.cs
+System.ServiceModel.Description/MetadataSetTest.cs
 System.ServiceModel.Description/OperationDescriptionTest.cs
 System.ServiceModel.Description/ServiceAuthorizationBehaviorTest.cs
 System.ServiceModel.Description/ServiceContractGeneratorTest.cs
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel.Description/MetadataSetTest.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel.Description/MetadataSetTest.cs
new file mode 100644 (file)
index 0000000..003ca65
--- /dev/null
@@ -0,0 +1,63 @@
+//
+// MetadataSetTest.cs
+//
+// Author:
+//     Atsushi Enomoto  <atsushi@ximian.com>
+//
+// Copyright (C) 2011 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.Linq;
+using System.Text;
+using System.Runtime.Serialization;
+using System.ServiceModel;
+using System.ServiceModel.Description;
+using System.Xml;
+
+using NUnit.Framework;
+
+namespace MonoTests.System.ServiceModel.Description
+{
+       [TestFixture]
+       public class MetadataSetTest
+       {
+               [Test]
+               [ExpectedException (typeof (ArgumentNullException))]
+               public void ReadFromNull ()
+               {
+                       MetadataSet.ReadFrom (null);
+               }
+
+               [Test]
+               [Category ("NotWorking")]
+               public void ReadFrom ()
+               {
+                       XmlReader xr = XmlTextReader.Create ("Test/XmlFiles/one.xml");
+                       var metadata = MetadataSet.ReadFrom (xr);
+                       Assert.AreEqual (5, metadata.MetadataSections.Count, "#1");
+                       Assert.AreEqual (2, metadata.MetadataSections.Where (m => m.Dialect == MetadataSection.ServiceDescriptionDialect).Count (), "#2");
+                       Assert.AreEqual (3, metadata.MetadataSections.Where (m => m.Dialect == MetadataSection.XmlSchemaDialect).Count (), "#3");
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Test/XmlFiles/one.xml b/mcs/class/System.ServiceModel/Test/XmlFiles/one.xml
new file mode 100644 (file)
index 0000000..ecfccd4
--- /dev/null
@@ -0,0 +1,154 @@
+<Metadata xmlns="http://schemas.xmlsoap.org/ws/2004/09/mex" xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex">
+  <wsx:MetadataSection Dialect="http://schemas.xmlsoap.org/wsdl/" Identifier="http://myns/echo" xmlns="">
+    <wsdl:definitions targetNamespace="http://myns/echo" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns="http://myns/echo" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsap="http://schemas.xmlsoap.org/ws/2004/08/addressing/policy" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msc="http://schemas.microsoft.com/ws/2005/12/wsdl/contract" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:wsa10="http://www.w3.org/2005/08/addressing">
+      <wsdl:types>
+        <xsd:schema targetNamespace="http://myns/echo/Imports">
+          <xsd:import namespace="http://myns/echo"/>
+          <xsd:import namespace="http://schemas.microsoft.com/2003/10/Serialization/"/>
+          <xsd:import namespace="http://schemas.datacontract.org/2004/07/"/>
+        </xsd:schema>
+      </wsdl:types>
+      <wsdl:message name="IEchoService_Echo_InputMessage">
+        <wsdl:part name="parameters" element="tns:Echo"/>
+      </wsdl:message>
+      <wsdl:message name="IEchoService_Echo_OutputMessage">
+        <wsdl:part name="parameters" element="tns:EchoResponse"/>
+      </wsdl:message>
+      <wsdl:message name="IEchoService_DoubleIt_InputMessage">
+        <wsdl:part name="parameters" element="tns:DoubleIt"/>
+      </wsdl:message>
+      <wsdl:message name="IEchoService_DoubleIt_OutputMessage">
+        <wsdl:part name="parameters" element="tns:DoubleItResponse"/>
+      </wsdl:message>
+      <wsdl:portType name="IEchoService">
+        <wsdl:operation name="Echo">
+          <wsdl:input wsaw:Action="http://myns/echo/IEchoService/Echo" message="tns:IEchoService_Echo_InputMessage"/>
+          <wsdl:output wsaw:Action="http://myns/echo/IEchoService/EchoResponse" message="tns:IEchoService_Echo_OutputMessage"/>
+        </wsdl:operation>
+        <wsdl:operation name="DoubleIt">
+          <wsdl:input wsaw:Action="http://myns/echo/IEchoService/DoubleIt" message="tns:IEchoService_DoubleIt_InputMessage"/>
+          <wsdl:output wsaw:Action="http://myns/echo/IEchoService/DoubleItResponse" message="tns:IEchoService_DoubleIt_OutputMessage"/>
+        </wsdl:operation>
+      </wsdl:portType>
+    </wsdl:definitions>
+  </wsx:MetadataSection>
+  <wsx:MetadataSection Dialect="http://schemas.xmlsoap.org/wsdl/" Identifier="http://tempuri.org/" xmlns="">
+    <wsdl:definitions name="EchoService" targetNamespace="http://tempuri.org/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns="http://tempuri.org/" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:i0="http://myns/echo" xmlns:wsap="http://schemas.xmlsoap.org/ws/2004/08/addressing/policy" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msc="http://schemas.microsoft.com/ws/2005/12/wsdl/contract" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:wsa10="http://www.w3.org/2005/08/addressing">
+      <wsdl:import namespace="http://myns/echo" location=""/>
+      <wsdl:types/>
+      <wsdl:binding name="BasicHttpBinding_IEchoService" type="i0:IEchoService">
+        <soap:binding transport="http://schemas.xmlsoap.org/soap/http"/>
+        <wsdl:operation name="Echo">
+          <soap:operation soapAction="http://myns/echo/IEchoService/Echo" style="document"/>
+          <wsdl:input>
+            <soap:body use="literal"/>
+          </wsdl:input>
+          <wsdl:output>
+            <soap:body use="literal"/>
+          </wsdl:output>
+        </wsdl:operation>
+        <wsdl:operation name="DoubleIt">
+          <soap:operation soapAction="http://myns/echo/IEchoService/DoubleIt" style="document"/>
+          <wsdl:input>
+            <soap:body use="literal"/>
+          </wsdl:input>
+          <wsdl:output>
+            <soap:body use="literal"/>
+          </wsdl:output>
+        </wsdl:operation>
+      </wsdl:binding>
+      <wsdl:service name="EchoService">
+        <wsdl:port name="BasicHttpBinding_IEchoService" binding="tns:BasicHttpBinding_IEchoService">
+          <soap:address location="http://192.168.0.1:8080/echo/svc"/>
+        </wsdl:port>
+      </wsdl:service>
+    </wsdl:definitions>
+  </wsx:MetadataSection>
+  <wsx:MetadataSection Dialect="http://www.w3.org/2001/XMLSchema" Identifier="http://myns/echo" xmlns="">
+    <xs:schema elementFormDefault="qualified" targetNamespace="http://myns/echo" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://myns/echo">
+      <xs:import namespace="http://schemas.datacontract.org/2004/07/"/>
+      <xs:element name="Echo">
+        <xs:complexType>
+          <xs:sequence>
+            <xs:element minOccurs="0" name="msg" nillable="true" type="xs:string"/>
+            <xs:element minOccurs="0" name="num" type="xs:int"/>
+            <xs:element minOccurs="0" name="d" nillable="true" type="q1:dc" xmlns:q1="http://schemas.datacontract.org/2004/07/"/>
+          </xs:sequence>
+        </xs:complexType>
+      </xs:element>
+      <xs:element name="EchoResponse">
+        <xs:complexType>
+          <xs:sequence>
+            <xs:element minOccurs="0" name="EchoResult" nillable="true" type="xs:string"/>
+          </xs:sequence>
+        </xs:complexType>
+      </xs:element>
+      <xs:element name="DoubleIt">
+        <xs:complexType>
+          <xs:sequence>
+            <xs:element minOccurs="0" name="it" type="xs:int"/>
+            <xs:element minOccurs="0" name="prefix" nillable="true" type="xs:string"/>
+          </xs:sequence>
+        </xs:complexType>
+      </xs:element>
+      <xs:element name="DoubleItResponse">
+        <xs:complexType>
+          <xs:sequence>
+            <xs:element minOccurs="0" name="DoubleItResult" nillable="true" type="xs:string"/>
+          </xs:sequence>
+        </xs:complexType>
+      </xs:element>
+    </xs:schema>
+  </wsx:MetadataSection>
+  <wsx:MetadataSection Dialect="http://www.w3.org/2001/XMLSchema" Identifier="http://schemas.microsoft.com/2003/10/Serialization/" xmlns="">
+    <xs:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://schemas.microsoft.com/2003/10/Serialization/" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://schemas.microsoft.com/2003/10/Serialization/">
+      <xs:element name="anyType" nillable="true" type="xs:anyType"/>
+      <xs:element name="anyURI" nillable="true" type="xs:anyURI"/>
+      <xs:element name="base64Binary" nillable="true" type="xs:base64Binary"/>
+      <xs:element name="boolean" nillable="true" type="xs:boolean"/>
+      <xs:element name="byte" nillable="true" type="xs:byte"/>
+      <xs:element name="dateTime" nillable="true" type="xs:dateTime"/>
+      <xs:element name="decimal" nillable="true" type="xs:decimal"/>
+      <xs:element name="double" nillable="true" type="xs:double"/>
+      <xs:element name="float" nillable="true" type="xs:float"/>
+      <xs:element name="int" nillable="true" type="xs:int"/>
+      <xs:element name="long" nillable="true" type="xs:long"/>
+      <xs:element name="QName" nillable="true" type="xs:QName"/>
+      <xs:element name="short" nillable="true" type="xs:short"/>
+      <xs:element name="string" nillable="true" type="xs:string"/>
+      <xs:element name="unsignedByte" nillable="true" type="xs:unsignedByte"/>
+      <xs:element name="unsignedInt" nillable="true" type="xs:unsignedInt"/>
+      <xs:element name="unsignedLong" nillable="true" type="xs:unsignedLong"/>
+      <xs:element name="unsignedShort" nillable="true" type="xs:unsignedShort"/>
+      <xs:element name="char" nillable="true" type="tns:char"/>
+      <xs:simpleType name="char">
+        <xs:restriction base="xs:int"/>
+      </xs:simpleType>
+      <xs:element name="duration" nillable="true" type="tns:duration"/>
+      <xs:simpleType name="duration">
+        <xs:restriction base="xs:duration">
+          <xs:pattern value="\-?P(\d*D)?(T(\d*H)?(\d*M)?(\d*(\.\d*)?S)?)?"/>
+          <xs:minInclusive value="-P10675199DT2H48M5.4775808S"/>
+          <xs:maxInclusive value="P10675199DT2H48M5.4775807S"/>
+        </xs:restriction>
+      </xs:simpleType>
+      <xs:element name="guid" nillable="true" type="tns:guid"/>
+      <xs:simpleType name="guid">
+        <xs:restriction base="xs:string">
+          <xs:pattern value="[\da-fA-F]{8}-[\da-fA-F]{4}-[\da-fA-F]{4}-[\da-fA-F]{4}-[\da-fA-F]{12}"/>
+        </xs:restriction>
+      </xs:simpleType>
+      <xs:attribute name="FactoryType" type="xs:QName"/>
+    </xs:schema>
+  </wsx:MetadataSection>
+  <wsx:MetadataSection Dialect="http://www.w3.org/2001/XMLSchema" Identifier="http://schemas.datacontract.org/2004/07/" xmlns="">
+    <xs:schema elementFormDefault="qualified" targetNamespace="http://schemas.datacontract.org/2004/07/" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://schemas.datacontract.org/2004/07/">
+      <xs:complexType name="dc">
+        <xs:sequence>
+          <xs:element minOccurs="0" name="foo" nillable="true" type="xs:string"/>
+        </xs:sequence>
+      </xs:complexType>
+      <xs:element name="dc" nillable="true" type="tns:dc"/>
+    </xs:schema>
+  </wsx:MetadataSection>
+</Metadata>