[mapguide-commits] r9363 - in trunk/MgDev: Common/MapGuideCommon/Resources Common/PlatformBase/Services Server/src/UnitTesting

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Tue Mar 6 06:52:05 PST 2018


Author: jng
Date: 2018-03-06 06:52:05 -0800 (Tue, 06 Mar 2018)
New Revision: 9363

Modified:
   trunk/MgDev/Common/MapGuideCommon/Resources/mapguide_en.res
   trunk/MgDev/Common/PlatformBase/Services/ResourceIdentifier.cpp
   trunk/MgDev/Server/src/UnitTesting/TestMisc.cpp
   trunk/MgDev/Server/src/UnitTesting/TestMisc.h
Log:
Include bad identifier in exception message if "new MgResourceIdentifier()" throws.

Fixes #2582

Modified: trunk/MgDev/Common/MapGuideCommon/Resources/mapguide_en.res
===================================================================
--- trunk/MgDev/Common/MapGuideCommon/Resources/mapguide_en.res	2018-03-06 14:27:16 UTC (rev 9362)
+++ trunk/MgDev/Common/MapGuideCommon/Resources/mapguide_en.res	2018-03-06 14:52:05 UTC (rev 9363)
@@ -160,6 +160,7 @@
 [ErrorDescription]
 MgArgumentsMismatch                                   = The arguments needed do not match the arguments provided.
 MgArgumentOutOfRange                                  = Argument out of range [%1, %2]: %3
+MgBadResourceIdentifer                                = Bad Resource Identifier: %1
 MgClassWOIdentity                                     = A class definition has no identity property.
 MgCannotResolveFeatureSourceFromWfsTypeName           = Could not resolve the Feature Source from the given WFS Type Name: %1
 MgCollectionEmpty                                     = The collection cannot be empty.

Modified: trunk/MgDev/Common/PlatformBase/Services/ResourceIdentifier.cpp
===================================================================
--- trunk/MgDev/Common/PlatformBase/Services/ResourceIdentifier.cpp	2018-03-06 14:27:16 UTC (rev 9362)
+++ trunk/MgDev/Common/PlatformBase/Services/ResourceIdentifier.cpp	2018-03-06 14:52:05 UTC (rev 9363)
@@ -451,8 +451,10 @@
     }
     else
     {
+        MgStringCollection args;
+        args.Add(resource);
         throw new MgInvalidRepositoryTypeException(
-            L"MgResourceIdentifier.ParseIdentifier", __LINE__,  __WFILE__, NULL, L"", NULL);
+            L"MgResourceIdentifier.ParseIdentifier", __LINE__,  __WFILE__, NULL, L"MgBadResourceIdentifer", &args);
     }
 
     Validate();

Modified: trunk/MgDev/Server/src/UnitTesting/TestMisc.cpp
===================================================================
--- trunk/MgDev/Server/src/UnitTesting/TestMisc.cpp	2018-03-06 14:27:16 UTC (rev 9362)
+++ trunk/MgDev/Server/src/UnitTesting/TestMisc.cpp	2018-03-06 14:52:05 UTC (rev 9363)
@@ -752,4 +752,23 @@
     {
         throw;
     }
+}
+
+void TestMisc::TestCase_BadResourceIdentifier()
+{
+    try
+    {
+        Ptr<MgResourceIdentifier> resId = new MgResourceIdentifier(L"I'm a baaaaad id");
+        CPPUNIT_FAIL("This should've thrown");
+    }
+    catch (MgException* e)
+    {
+        STRING message = e->GetDetails(TEST_LOCALE);
+        SAFE_RELEASE(e);
+        CPPUNIT_ASSERT(message.find(L"I'm a baaaaad id") != STRING::npos);
+    }
+    catch (...)
+    {
+        throw;
+    }
 }
\ No newline at end of file

Modified: trunk/MgDev/Server/src/UnitTesting/TestMisc.h
===================================================================
--- trunk/MgDev/Server/src/UnitTesting/TestMisc.h	2018-03-06 14:27:16 UTC (rev 9362)
+++ trunk/MgDev/Server/src/UnitTesting/TestMisc.h	2018-03-06 14:52:05 UTC (rev 9363)
@@ -33,6 +33,7 @@
     CPPUNIT_TEST(TestCase_ApiVersionCheck);
     CPPUNIT_TEST(TestCase_DoubleToStringWithDecimals);
     CPPUNIT_TEST(TestCase_TryParseDouble);
+    CPPUNIT_TEST(TestCase_BadResourceIdentifier);
 
     CPPUNIT_TEST(TestEnd); // This must be the very last unit test
     CPPUNIT_TEST_SUITE_END();
@@ -55,6 +56,7 @@
     void TestCase_ApiVersionCheck();
     void TestCase_DoubleToStringWithDecimals();
     void TestCase_TryParseDouble();
+    void TestCase_BadResourceIdentifier();
 
 private:
     Ptr<MgSiteConnection> m_siteConnection;



More information about the mapguide-commits mailing list