[mapguide-commits] r4902 - in sandbox/maestro-2.5: MaestroAPITests
OSGeo.MapGuide.MaestroAPI OSGeo.MapGuide.MaestroAPI/Exceptions
OSGeo.MapGuide.MaestroAPI.Http
svn_mapguide at osgeo.org
svn_mapguide at osgeo.org
Mon May 17 21:33:36 EDT 2010
Author: jng
Date: 2010-05-17 21:33:35 -0400 (Mon, 17 May 2010)
New Revision: 4902
Added:
sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/Exceptions/UnsupportedServiceTypeException.cs
Modified:
sandbox/maestro-2.5/MaestroAPITests/HttpConnectionTests.cs
sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI.Http/HttpServerConnection.cs
sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/OSGeo.MapGuide.MaestroAPI.csproj
sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/ServerConnectionBase.cs
Log:
Add unit tests to verify IConnectionCapabilities.SupportedServices lines up with IServerConnection.GetService()
Modified: sandbox/maestro-2.5/MaestroAPITests/HttpConnectionTests.cs
===================================================================
--- sandbox/maestro-2.5/MaestroAPITests/HttpConnectionTests.cs 2010-05-18 01:17:57 UTC (rev 4901)
+++ sandbox/maestro-2.5/MaestroAPITests/HttpConnectionTests.cs 2010-05-18 01:33:35 UTC (rev 4902)
@@ -22,6 +22,7 @@
using System.Text;
using NUnit.Framework;
using OSGeo.MapGuide.MaestroAPI;
+using OSGeo.MapGuide.MaestroAPI.Services;
namespace MaestroAPITests
{
@@ -53,5 +54,43 @@
var agent = (string)isvc.GetCustomProperty("UserAgent");
Assert.AreEqual(agent, "MapGuide Maestro API Unit Test Fixture");
}
+
+ [Test]
+ public void TestServiceCapabilities()
+ {
+ var builder = new RequestBuilder(new Uri("http://tempuri.org"), "en");
+ var conn = new HttpServerConnection(builder);
+ conn.SetSiteVersion(new Version(1, 2, 0));
+
+ //Work through the interface
+ IServerConnection isvc = (IServerConnection)conn;
+ int[] stypes = isvc.Capabilities.SupportedServices;
+ foreach (int st in stypes)
+ {
+ try
+ {
+ IService svc = isvc.GetService(st);
+ }
+ catch
+ {
+ Assert.Fail("Supported service type mismatch");
+ }
+ }
+
+ conn.SetSiteVersion(new Version(2, 0, 0));
+
+ stypes = isvc.Capabilities.SupportedServices;
+ foreach (int st in stypes)
+ {
+ try
+ {
+ IService svc = isvc.GetService(st);
+ }
+ catch
+ {
+ Assert.Fail("Supported service type mismatch");
+ }
+ }
+ }
}
}
Added: sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/Exceptions/UnsupportedServiceTypeException.cs
===================================================================
--- sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/Exceptions/UnsupportedServiceTypeException.cs (rev 0)
+++ sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/Exceptions/UnsupportedServiceTypeException.cs 2010-05-18 01:33:35 UTC (rev 4902)
@@ -0,0 +1,47 @@
+#region Disclaimer / License
+// Copyright (C) 2010, Jackie Ng
+// http://trac.osgeo.org/mapguide/wiki/maestro, jumpinjackie at gmail.com
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+//
+#endregion
+using System;
+using System.Collections.Generic;
+using System.Text;
+using OSGeo.MapGuide.MaestroAPI.Services;
+
+namespace OSGeo.MapGuide.MaestroAPI.Exceptions
+{
+ [global::System.Serializable]
+ public class UnsupportedServiceTypeException : MaestroException
+ {
+ //
+ // For guidelines regarding the creation of new exception types, see
+ // http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconerrorraisinghandlingguidelines.asp
+ // and
+ // http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dncscol/html/csharp07192001.asp
+ //
+
+ public UnsupportedServiceTypeException(ServiceType st) { this.ServiceType = st; }
+ public UnsupportedServiceTypeException(ServiceType st, string message) : base(message) { this.ServiceType = st; }
+ public UnsupportedServiceTypeException(ServiceType st, string message, Exception inner) : base(message, inner) { this.ServiceType = st; }
+ protected UnsupportedServiceTypeException(
+ System.Runtime.Serialization.SerializationInfo info,
+ System.Runtime.Serialization.StreamingContext context)
+ : base(info, context) { }
+
+ public ServiceType ServiceType { get; private set; }
+ }
+}
Modified: sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/OSGeo.MapGuide.MaestroAPI.csproj
===================================================================
--- sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/OSGeo.MapGuide.MaestroAPI.csproj 2010-05-18 01:17:57 UTC (rev 4901)
+++ sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/OSGeo.MapGuide.MaestroAPI.csproj 2010-05-18 01:33:35 UTC (rev 4902)
@@ -171,6 +171,7 @@
<Compile Include="Exceptions\MaestroException.cs" />
<Compile Include="Exceptions\ResourceConversionException.cs" />
<Compile Include="Exceptions\UnsupportedResourceTypeException.cs" />
+ <Compile Include="Exceptions\UnsupportedServiceTypeException.cs" />
<Compile Include="IConnectionCapabilities.cs" />
<Compile Include="MaestroApiProviderAttribute.cs" />
<Compile Include="ConnectionProviderRegistry.cs" />
Modified: sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/ServerConnectionBase.cs
===================================================================
--- sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/ServerConnectionBase.cs 2010-05-18 01:17:57 UTC (rev 4901)
+++ sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/ServerConnectionBase.cs 2010-05-18 01:33:35 UTC (rev 4902)
@@ -1267,7 +1267,7 @@
}
- abstract public Version SiteVersion { get; }
+ abstract public Version SiteVersion { get; }
/// <summary>
/// Determines if an exception is a "Session Expired" exception.
Modified: sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI.Http/HttpServerConnection.cs
===================================================================
--- sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI.Http/HttpServerConnection.cs 2010-05-18 01:17:57 UTC (rev 4901)
+++ sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI.Http/HttpServerConnection.cs 2010-05-18 01:33:35 UTC (rev 4902)
@@ -47,7 +47,8 @@
IResourceService,
ITileService,
IMappingService,
- IDrawingService
+ IDrawingService,
+ IFusionService
{
private WebClient m_wc;
private RequestBuilder m_reqBuilder;
@@ -783,8 +784,17 @@
return m;
}
- public override Version SiteVersion { get { return m_siteVersion; } }
+ public override Version SiteVersion
+ {
+ get { return m_siteVersion; }
+ }
+ //For unit testing purposes
+ internal void SetSiteVersion(Version v)
+ {
+ m_siteVersion = v;
+ }
+
private ICoordinateSystemCatalog m_coordsys = null;
//TODO: Figure out a strategy for cache invalidation
//TODO: Figure out if this can work with MapGuide EP 1.0 (just exclude it?)
@@ -1534,7 +1544,21 @@
public IService GetService(int serviceType)
{
- throw new NotImplementedException();
+ ServiceType st = (ServiceType)serviceType;
+ switch (st)
+ {
+ case ServiceType.Drawing:
+ case ServiceType.Feature:
+ case ServiceType.Mapping:
+ case ServiceType.Resource:
+ case ServiceType.Tile:
+ return this;
+ case ServiceType.Fusion:
+ if (this.SiteVersion >= new Version(2, 0))
+ return this;
+ break;
+ }
+ throw new UnsupportedServiceTypeException(st);
}
public void SaveResource(OSGeo.MapGuide.MaestroAPI.Resource.IResource resource)
@@ -1627,5 +1651,20 @@
{
throw new NotImplementedException();
}
+
+ ApplicationDefinitionTemplateInfoSet IFusionService.GetApplicationTemplates()
+ {
+ throw new NotImplementedException();
+ }
+
+ ApplicationDefinitionWidgetInfoSet IFusionService.GetApplicationWidgets()
+ {
+ throw new NotImplementedException();
+ }
+
+ ApplicationDefinitionContainerInfoSet IFusionService.GetApplicationContainers()
+ {
+ throw new NotImplementedException();
+ }
}
}
More information about the mapguide-commits
mailing list