[mapguide-commits] r1066 - trunk/MgDev/Server/src/UnitTesting

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Mon Jan 22 19:03:20 EST 2007


Author: brucedechant
Date: 2007-01-22 19:03:19 -0500 (Mon, 22 Jan 2007)
New Revision: 1066

Modified:
   trunk/MgDev/Server/src/UnitTesting/TestResourceService.cpp
Log:
Update resource service unit test.

Modified: trunk/MgDev/Server/src/UnitTesting/TestResourceService.cpp
===================================================================
--- trunk/MgDev/Server/src/UnitTesting/TestResourceService.cpp	2007-01-23 00:01:30 UTC (rev 1065)
+++ trunk/MgDev/Server/src/UnitTesting/TestResourceService.cpp	2007-01-23 00:03:19 UTC (rev 1066)
@@ -1370,6 +1370,12 @@
             throw new MgServiceNotAvailableException(L"TestResourceService.TestCase_DeleteResource", __LINE__, __WFILE__, NULL, L"", NULL);
         }
 
+        Ptr<MgFeatureService> pFeatureService = dynamic_cast<MgFeatureService*>(serviceManager->RequestService(MgServiceType::FeatureService));
+        if (pFeatureService == 0)
+        {
+            throw new MgServiceNotAvailableException(L"TestResourceService.TestCase_DeleteResource", __LINE__, __WFILE__, NULL, L"", NULL);
+        }
+
         Ptr<MgUserInformation> userInfo;
 
         //Sets the user information for the current thread to be administrator
@@ -1401,6 +1407,54 @@
             MgUserInformation::SetCurrentUserInfo(userInfo);
             CPPUNIT_ASSERT_THROW_MG(pService->DeleteResource(&resourceIdentifier), MgUnauthorizedAccessException*);
         }
+
+        // Try to delete resource after FDO exception
+        MgUserInformation::SetCurrentUserInfo(NULL);
+        userInfo = new MgUserInformation(adminName, adminPass);
+        if (userInfo != NULL)
+        {
+            Ptr<MgResourceIdentifier> resource;
+            resource = new MgResourceIdentifier(L"Library://UnitTests/Data/TEST.FeatureSource");
+
+            #ifdef WIN32
+            STRING rcName = L"..\\UnitTestFiles\\TEST.FeatureSource";
+            STRING dfName = L"..\\UnitTestFiles\\TEST.sdf";
+            #else
+            STRING rcName = L"../UnitTestFiles/TEST.FeatureSource";
+            STRING dfName = L"../UnitTestFiles/TEST.sdf";
+            #endif
+
+            userInfo->SetLocale(userLocale);
+            MgUserInformation::SetCurrentUserInfo(userInfo);
+
+            Ptr<MgByteSource> contentSource;
+            contentSource = new MgByteSource(rcName);
+            Ptr<MgByteReader> contentReader = contentSource->GetReader();
+            pService->SetResource(resource, contentReader, NULL);
+
+            Ptr<MgByteSource> dataSource;
+            dataSource = new MgByteSource(dfName);
+
+            Ptr<MgByteReader> dataReader;
+            dataReader = dataSource->GetReader();
+            pService->SetResourceData(resource, L"TEST.sdf", L"File", dataReader);
+            dataReader = NULL; // Holds on to the file, so must release resources!
+
+            // Force an FDO exception
+            Ptr<MgFeatureAggregateOptions> options = new MgFeatureAggregateOptions();
+            STRING className = L"TEST";
+            options->AddFeatureProperty(L"Data");
+
+            Ptr<MgDataReader> reader = pFeatureService->SelectAggregate(resource, className, options);
+            bool bResult = reader->ReadNext();
+            CPPUNIT_ASSERT(bResult);
+
+            reader->Close();
+            reader = NULL; // Holds on to the file, so must release resources!
+
+            // Attempt to delete the resource
+            pService->DeleteResource(resource);
+        }
     }
     catch(MgException* e)
     {
@@ -1408,4 +1462,13 @@
         SAFE_RELEASE(e);
         CPPUNIT_FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
     }
+    catch(FdoException* e)
+    {
+        FDO_SAFE_RELEASE(e);
+        CPPUNIT_FAIL("FdoException occured");
+    }
+    catch(...)
+    {
+        throw;
+    }
 }



More information about the mapguide-commits mailing list