[mapguide-commits] r7233 - in sandbox/jng/swig-java: Common/PlatformBase/MapLayer Server/src/UnitTesting

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Mon Nov 26 22:11:18 PST 2012


Author: jng
Date: 2012-11-26 22:11:18 -0800 (Mon, 26 Nov 2012)
New Revision: 7233

Modified:
   sandbox/jng/swig-java/Common/PlatformBase/MapLayer/LayerCollection.cpp
   sandbox/jng/swig-java/Common/PlatformBase/MapLayer/LayerGroupCollection.cpp
   sandbox/jng/swig-java/Server/src/UnitTesting/TestMisc.cpp
   sandbox/jng/swig-java/Server/src/UnitTesting/TestMisc.h
Log:
Bring across collection fixes

Modified: sandbox/jng/swig-java/Common/PlatformBase/MapLayer/LayerCollection.cpp
===================================================================
--- sandbox/jng/swig-java/Common/PlatformBase/MapLayer/LayerCollection.cpp	2012-11-27 05:19:36 UTC (rev 7232)
+++ sandbox/jng/swig-java/Common/PlatformBase/MapLayer/LayerCollection.cpp	2012-11-27 06:11:18 UTC (rev 7233)
@@ -149,9 +149,9 @@
         Ptr<MgLayerBase> layer = SAFE_ADDREF(value);
 
         //value is released by m_layers base class
-        m_layers->Remove(value);
+        removed = m_layers->Remove(value);
 
-        if (m_owner)
+        if (m_owner && removed)
             m_owner->OnLayerRemoved(layer);
     }
     catch (MgException* e)

Modified: sandbox/jng/swig-java/Common/PlatformBase/MapLayer/LayerGroupCollection.cpp
===================================================================
--- sandbox/jng/swig-java/Common/PlatformBase/MapLayer/LayerGroupCollection.cpp	2012-11-27 05:19:36 UTC (rev 7232)
+++ sandbox/jng/swig-java/Common/PlatformBase/MapLayer/LayerGroupCollection.cpp	2012-11-27 06:11:18 UTC (rev 7233)
@@ -130,9 +130,9 @@
         Ptr<MgLayerGroup> group = SAFE_ADDREF(value);
 
         //value is released by m_groups base class
-        m_groups->Remove(value);
+        removed = m_groups->Remove(value);
 
-        if (m_owner)
+        if (m_owner && removed)
             m_owner->OnGroupRemoved(group);
     }
     catch (MgException* e)

Modified: sandbox/jng/swig-java/Server/src/UnitTesting/TestMisc.cpp
===================================================================
--- sandbox/jng/swig-java/Server/src/UnitTesting/TestMisc.cpp	2012-11-27 05:19:36 UTC (rev 7232)
+++ sandbox/jng/swig-java/Server/src/UnitTesting/TestMisc.cpp	2012-11-27 06:11:18 UTC (rev 7233)
@@ -509,4 +509,36 @@
     {
         throw;
     }
+}
+
+void TestMisc::TestCase_MapLayerCollections()
+{
+    try
+    {
+        Ptr<MgResourceIdentifier> mapRes1 = new MgResourceIdentifier(L"Library://UnitTests/Maps/Sheboygan.MapDefinition");
+        Ptr<MgMap> map1 = new MgMap(m_siteConnection);
+        map1->Create(mapRes1, L"UnitTestSheboygan1");
+
+        Ptr<MgLayerGroup> detachedGroup = new MgLayerGroup(L"DetachedGroup");
+        Ptr<MgResourceIdentifier> ldf = new MgResourceIdentifier(L"Library://UnitTests/Layers/Parcels.LayerDefinition");
+        Ptr<MgLayer> detachedLayer = new MgLayer(ldf, m_svcResource);
+        detachedLayer->SetName(L"DetachedLayer");
+
+        Ptr<MgLayerCollection> mapLayers = map1->GetLayers();
+        Ptr<MgLayerGroupCollection> mapGroups = map1->GetLayerGroups();
+
+        //Remove() should be returning false when passing in layers/groups that don't belong
+        CPPUNIT_ASSERT(!mapLayers->Remove(detachedLayer));
+        CPPUNIT_ASSERT(!mapGroups->Remove(detachedGroup));
+    }
+    catch (MgException* e)
+    {
+        STRING message = e->GetDetails(TEST_LOCALE);
+        SAFE_RELEASE(e);
+        CPPUNIT_FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
+    }
+    catch (...)
+    {
+        throw;
+    }
 }
\ No newline at end of file

Modified: sandbox/jng/swig-java/Server/src/UnitTesting/TestMisc.h
===================================================================
--- sandbox/jng/swig-java/Server/src/UnitTesting/TestMisc.h	2012-11-27 05:19:36 UTC (rev 7232)
+++ sandbox/jng/swig-java/Server/src/UnitTesting/TestMisc.h	2012-11-27 06:11:18 UTC (rev 7233)
@@ -28,6 +28,7 @@
     CPPUNIT_TEST(TestCase_CommonExceptionMessages);
     CPPUNIT_TEST(TestCase_611);
     CPPUNIT_TEST(TestCase_1304);
+    CPPUNIT_TEST(TestCase_MapLayerCollections);
 
     CPPUNIT_TEST(TestEnd); // This must be the very last unit test
     CPPUNIT_TEST_SUITE_END();
@@ -44,6 +45,7 @@
     void TestCase_CommonExceptionMessages();
     void TestCase_611();
     void TestCase_1304();
+    void TestCase_MapLayerCollections();
 
 private:
     Ptr<MgSiteConnection> m_siteConnection;



More information about the mapguide-commits mailing list