[mapguide-commits] r6309 - in trunk/Tools/Maestro: MaestroAPITests OSGeo.MapGuide.MaestroAPI/Mapping OSGeo.MapGuide.MaestroAPI.Http

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Thu Dec 8 05:18:25 EST 2011


Author: jng
Date: 2011-12-08 02:18:25 -0800 (Thu, 08 Dec 2011)
New Revision: 6309

Modified:
   trunk/Tools/Maestro/MaestroAPITests/HttpConnectionTests.cs
   trunk/Tools/Maestro/MaestroAPITests/RuntimeMapTests.cs
   trunk/Tools/Maestro/MaestroAPITests/TestControl.cs
   trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI.Http/RequestBuilder.cs
   trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI.Http/XmlFeatureReader.cs
   trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Mapping/RuntimeMap.cs
Log:
#1882: Fix bad order of deserialization of 2.3 Runtime Map state
Also fix SetResourceData requiring a seekable stream. Turns out the DATALENGTH request parameter is not even being used by MapGuide Web Tier! So we don't set it.

Extra unit tests have been added to verify these changes.

Modified: trunk/Tools/Maestro/MaestroAPITests/HttpConnectionTests.cs
===================================================================
--- trunk/Tools/Maestro/MaestroAPITests/HttpConnectionTests.cs	2011-12-08 09:38:00 UTC (rev 6308)
+++ trunk/Tools/Maestro/MaestroAPITests/HttpConnectionTests.cs	2011-12-08 10:18:25 UTC (rev 6309)
@@ -24,6 +24,7 @@
 using OSGeo.MapGuide.MaestroAPI;
 using OSGeo.MapGuide.MaestroAPI.Services;
 using System.IO;
+using OSGeo.MapGuide.ObjectModels.Common;
 
 namespace MaestroAPITests
 {
@@ -124,14 +125,37 @@
         }
 
         [Test]
-        public void TestAnyStreamInput()
+        public void TestTouch()
         {
             var conn = ConnectionUtil.CreateTestHttpConnection();
             var resSvc = conn.ResourceService;
             if (!resSvc.ResourceExists("Library://UnitTests/Data/HydrographicPolygons.FeatureSource"))
                 resSvc.SetResourceXmlData("Library://UnitTests/Data/HydrographicPolygons.FeatureSource", File.OpenRead("TestData/MappingService/UT_HydrographicPolygons.fs"));
 
-            resSvc.SetResourceXmlData("Library://UnitTests/Data/TestAnyStreamInput.FeatureSource", resSvc.GetResourceXmlData("Library://UnitTests/Data/HydrographicPolygons.FeatureSource"));
+            resSvc.Touch("Library://UnitTests/Data/HydrographicPolygons.FeatureSource");
         }
+
+        [Test]
+        public void TestAnyStreamInput()
+        {
+            string source = "Library://UnitTests/Data/HydrographicPolygons.FeatureSource";
+            string target = "Library://UnitTests/Data/TestAnyStreamInput.FeatureSource";
+
+            var conn = ConnectionUtil.CreateTestHttpConnection();
+            var resSvc = conn.ResourceService;
+            if (!resSvc.ResourceExists(source))
+                resSvc.SetResourceXmlData(source, File.OpenRead("TestData/MappingService/UT_HydrographicPolygons.fs"));
+
+            resSvc.SetResourceXmlData(target, resSvc.GetResourceXmlData(source));
+
+            string dataName = "";
+            var resDataList = resSvc.EnumerateResourceData(source);
+            dataName = resDataList.ResourceData[0].Name;
+
+            resSvc.SetResourceData(target,
+                                   dataName,
+                                   ResourceDataType.File,
+                                   resSvc.GetResourceData(source, dataName));
+        }
     }
 }

Modified: trunk/Tools/Maestro/MaestroAPITests/RuntimeMapTests.cs
===================================================================
--- trunk/Tools/Maestro/MaestroAPITests/RuntimeMapTests.cs	2011-12-08 09:38:00 UTC (rev 6308)
+++ trunk/Tools/Maestro/MaestroAPITests/RuntimeMapTests.cs	2011-12-08 10:18:25 UTC (rev 6309)
@@ -1027,17 +1027,6 @@
         }
     }
 
-    public class ConnectionUtil
-    {
-        public static IServerConnection CreateTestHttpConnection()
-        {
-            return ConnectionProviderRegistry.CreateConnection("Maestro.Http",
-                "Url", "http://" + Environment.MachineName + "/mapguide/mapagent/mapagent.fcgi",
-                "Username", "Administrator",
-                "Password", "admin");
-        }
-    }
-
     [TestFixture(Ignore = TestControl.IgnoreHttpRuntimeMapTests)]
     public class HttpRuntimeMapTests : RuntimeMapTests
     {
@@ -1045,7 +1034,7 @@
         {
             return ConnectionUtil.CreateTestHttpConnection();
         }
-        /*
+        
         [Test]
         public override void TestResourceEvents()
         {
@@ -1105,7 +1094,7 @@
         {
             base.TestLargeMapCreatePerformance();
         }
-        */
+        
         [Test]
         public override void TestMapManipulation4()
         {

Modified: trunk/Tools/Maestro/MaestroAPITests/TestControl.cs
===================================================================
--- trunk/Tools/Maestro/MaestroAPITests/TestControl.cs	2011-12-08 09:38:00 UTC (rev 6308)
+++ trunk/Tools/Maestro/MaestroAPITests/TestControl.cs	2011-12-08 10:18:25 UTC (rev 6309)
@@ -20,6 +20,7 @@
 using System;
 using System.Collections.Generic;
 using System.Text;
+using OSGeo.MapGuide.MaestroAPI;
 
 namespace MaestroAPITests
 {
@@ -41,4 +42,15 @@
         public const bool IgnoreSerializationTests = false;
         public const bool IgnoreValidationTests = false;
     }
+
+    public class ConnectionUtil
+    {
+        public static IServerConnection CreateTestHttpConnection()
+        {
+            return ConnectionProviderRegistry.CreateConnection("Maestro.Http",
+                "Url", "http://" + Environment.MachineName + "/mapguide/mapagent/mapagent.fcgi",
+                "Username", "Administrator",
+                "Password", "admin");
+        }
+    }
 }

Modified: trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Mapping/RuntimeMap.cs
===================================================================
--- trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Mapping/RuntimeMap.cs	2011-12-08 09:38:00 UTC (rev 6308)
+++ trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Mapping/RuntimeMap.cs	2011-12-08 10:18:25 UTC (rev 6309)
@@ -824,7 +824,10 @@
             if (d.SiteVersion >= SiteVersions.GetVersion(KnownSiteVersions.MapGuideOS1_2))
             {
                 m_changeList = DeserializeChangeMap(d);
-
+                if (d.SiteVersion >= new Version(2, 3))
+                {
+                    this.WatermarkUsage = d.ReadInt32();
+                }
                 int mapLayerCount = d.ReadInt32();
                 if (mapLayerCount != 0)
                     throw new Exception("On new versions, there should be no layer data in map");
@@ -837,11 +840,6 @@
                 m_changeList = DeserializeChangeMap(d);
             }
 
-            if (d.SiteVersion >= SiteVersions.GetVersion(KnownSiteVersions.MapGuideEP2012))
-            {
-                this.WatermarkUsage = d.ReadInt32();
-            }
-
             _disableChangeTracking = false;
         }
 

Modified: trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI.Http/RequestBuilder.cs
===================================================================
--- trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI.Http/RequestBuilder.cs	2011-12-08 09:38:00 UTC (rev 6308)
+++ trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI.Http/RequestBuilder.cs	2011-12-08 10:18:25 UTC (rev 6309)
@@ -449,8 +449,12 @@
 			param.Add("RESOURCEID", id);
 			param.Add("DATANAME", dataname);
 			param.Add("DATATYPE", datatype.ToString());
-			param.Add("DATALENGTH", content.Length.ToString());
 
+            //This does not appear to be used anywhere in the MG WebTier code
+            //anyway, set this if stream supports seeking
+            if (content.CanSeek)
+			    param.Add("DATALENGTH", content.Length.ToString());
+
 			string boundary;
 			System.Net.WebRequest req = PrepareFormContent(outStream, out boundary);
 

Modified: trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI.Http/XmlFeatureReader.cs
===================================================================
--- trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI.Http/XmlFeatureReader.cs	2011-12-08 09:38:00 UTC (rev 6308)
+++ trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI.Http/XmlFeatureReader.cs	2011-12-08 10:18:25 UTC (rev 6309)
@@ -60,7 +60,7 @@
             if (_reader.Name != this.ResponseRootElement)
                 throw new Exception("Bad document. Expected element: " + this.ResponseRootElement); //LOCALIZEME
             _reader.Read();
-            //FIXME: serialized schema not included in queries for extended feature classes!
+            //FIXME: Gracefully handle empty result sets. Empty result sets do not include a schema element
             if (_reader.Name != this.DefinitionRootElement)
                 throw new Exception("Bad document. Expected element: " + this.DefinitionRootElement); //LOCALIZEME
 



More information about the mapguide-commits mailing list