[mapguide-commits] r9370 - in branches/3.1/MgDev: . Common/PlatformBase/Services Server/src/UnitTesting

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Wed Mar 14 09:59:13 PDT 2018


Author: jng
Date: 2018-03-14 09:59:13 -0700 (Wed, 14 Mar 2018)
New Revision: 9370

Modified:
   branches/3.1/MgDev/
   branches/3.1/MgDev/Common/PlatformBase/Services/FeatureReader.cpp
   branches/3.1/MgDev/Server/src/UnitTesting/TestFeatureService.cpp
   branches/3.1/MgDev/Server/src/UnitTesting/TestFeatureService.h
Log:
Merged revision(s) 9369 from trunk/MgDev:
Don't throw on bad property name in GetPropertyIndex, just return -1. This is the expected contract that other reader types already fulfil. Why should MgFeatureReader be an exception?

Fixes #2480
........


Index: branches/3.1/MgDev
===================================================================
--- branches/3.1/MgDev	2018-03-14 16:55:55 UTC (rev 9369)
+++ branches/3.1/MgDev	2018-03-14 16:59:13 UTC (rev 9370)

Property changes on: branches/3.1/MgDev
___________________________________________________________________
Modified: svn:mergeinfo
## -15,4 +15,4 ##
 /sandbox/jng/tiling:8174-8208
 /sandbox/jng/v30:8212-8227
 /sandbox/rfc94:5099-5163
-/trunk/MgDev:8955-8956,8969,8980-8981,8986,8996,9000,9004-9006,9010,9018-9021,9034,9038,9042,9094,9106-9107,9147,9339-9343,9353,9360,9363
\ No newline at end of property
+/trunk/MgDev:8955-8956,8969,8980-8981,8986,8996,9000,9004-9006,9010,9018-9021,9034,9038,9042,9094,9106-9107,9147,9339-9343,9353,9360,9363,9369
\ No newline at end of property
Modified: branches/3.1/MgDev/Common/PlatformBase/Services/FeatureReader.cpp
===================================================================
--- branches/3.1/MgDev/Common/PlatformBase/Services/FeatureReader.cpp	2018-03-14 16:55:55 UTC (rev 9369)
+++ branches/3.1/MgDev/Common/PlatformBase/Services/FeatureReader.cpp	2018-03-14 16:59:13 UTC (rev 9370)
@@ -68,18 +68,7 @@
     Ptr<MgPropertyDefinitionCollection> propDefCol = classDef->GetProperties();
     CHECKNULL((MgPropertyDefinitionCollection*)propDefCol, L"MgFeatureReader.GetPropertyIndex");
 
-    INT32 index = propDefCol->IndexOf(propertyName);
-    if (-1 != index)
-    {
-        return index;
-    }
-    else
-    {
-        MgStringCollection args;
-        args.Add(propertyName);
-        throw new MgObjectNotFoundException(L"MgFeatureReader.GetPropertyIndex", __LINE__, __WFILE__, NULL, L"MgNoNameForObject", &args);
-        return -1; // to suppress compiler warning.
-    }
+    return propDefCol->IndexOf(propertyName);
 }
 
 //////////////////////////////////////////////////////////////////

Modified: branches/3.1/MgDev/Server/src/UnitTesting/TestFeatureService.cpp
===================================================================
--- branches/3.1/MgDev/Server/src/UnitTesting/TestFeatureService.cpp	2018-03-14 16:55:55 UTC (rev 9369)
+++ branches/3.1/MgDev/Server/src/UnitTesting/TestFeatureService.cpp	2018-03-14 16:59:13 UTC (rev 9370)
@@ -3731,4 +3731,54 @@
     qClassName += L":";
     qClassName += theClass->GetName();
     return qClassName;
+}
+
+///----------------------------------------------------------------------------
+/// Test Case Description:
+///
+/// This test case exercises getting indices of invalid property names from
+/// the feature reader
+///----------------------------------------------------------------------------
+void TestFeatureService::TestCase_FeatureReader_GetPropertyIndex_BadProp()
+{
+    try
+    {
+        MgServiceManager* serviceManager = MgServiceManager::GetInstance();
+        if (serviceManager == 0)
+        {
+            throw new MgNullReferenceException(L"TestFeatureService.TestCase_FeatureReader_GetPropertyIndex_BadProp", __LINE__, __WFILE__, NULL, L"", NULL);
+        }
+
+        Ptr<MgFeatureService> pService = dynamic_cast<MgFeatureService*>(serviceManager->RequestService(MgServiceType::FeatureService));
+        if (pService == 0)
+        {
+            throw new MgServiceNotAvailableException(L"TestFeatureService.TestCase_FeatureReader_GetPropertyIndex_BadProp", __LINE__, __WFILE__, NULL, L"", NULL);
+        }
+
+        Ptr<MgResourceIdentifier> resource = new MgResourceIdentifier();
+        STRING className = L"";
+        Ptr<MgFeatureQueryOptions> options = new MgFeatureQueryOptions();
+        CPPUNIT_ASSERT_THROW_MG(pService->SelectFeatures(resource, className, options), MgInvalidArgumentException*);
+
+        resource = new MgResourceIdentifier(L"Library://UnitTests/Data/Sheboygan_Parcels.FeatureSource");
+        className = L"Parcels";
+        Ptr<MgFeatureReader> reader = pService->SelectFeatures(resource, className, options);
+        CPPUNIT_ASSERT(reader->GetPropertyIndex(L"IDontExist") < 0);
+        reader->Close();
+    }
+    catch (MgException* e)
+    {
+        STRING message = e->GetDetails(TEST_LOCALE);
+        SAFE_RELEASE(e);
+        CPPUNIT_FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
+    }
+    catch (FdoException* e)
+    {
+        FDO_SAFE_RELEASE(e);
+        CPPUNIT_FAIL("FdoException occurred");
+    }
+    catch (...)
+    {
+        throw;
+    }
 }
\ No newline at end of file

Modified: branches/3.1/MgDev/Server/src/UnitTesting/TestFeatureService.h
===================================================================
--- branches/3.1/MgDev/Server/src/UnitTesting/TestFeatureService.h	2018-03-14 16:55:55 UTC (rev 9369)
+++ branches/3.1/MgDev/Server/src/UnitTesting/TestFeatureService.h	2018-03-14 16:59:13 UTC (rev 9370)
@@ -69,6 +69,7 @@
     CPPUNIT_TEST(TestCase_JoinFdoFeatures);
     CPPUNIT_TEST(TestCase_BenchmarkSqliteJoin);
     CPPUNIT_TEST(TestCase_BenchmarkSqliteAggregateJoin);
+    CPPUNIT_TEST(TestCase_FeatureReader_GetPropertyIndex_BadProp);
 
     CPPUNIT_TEST(TestEnd); // This must be the very last unit test
     CPPUNIT_TEST_SUITE_END();
@@ -124,6 +125,7 @@
     void TestCase_JoinFdoFeatures();
     void TestCase_BenchmarkSqliteJoin();
     void TestCase_BenchmarkSqliteAggregateJoin();
+    void TestCase_FeatureReader_GetPropertyIndex_BadProp();
 
 private:
     STRING CreateTestDataStore(MgFeatureService* svcFeature, CREFSTRING provider, MgResourceIdentifier* fsId);



More information about the mapguide-commits mailing list