[mapguide-commits] r1080 - in trunk/MgDev/Server/src: Core UnitTesting

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Mon Jan 29 19:08:26 EST 2007


Author: tonyfang
Date: 2007-01-29 19:08:25 -0500 (Mon, 29 Jan 2007)
New Revision: 1080

Modified:
   trunk/MgDev/Server/src/Core/serverconfig.ini
   trunk/MgDev/Server/src/UnitTesting/TestResourceService.cpp
   trunk/MgDev/Server/src/UnitTesting/TestResourceService.h
   trunk/MgDev/Server/src/UnitTesting/TestServerAdminService.cpp
   trunk/MgDev/Server/src/UnitTesting/TestServerAdminService.h
Log:
MapGuide RFC 12 - Unmanaged Data API Changes
- added unit test for RemoveConfigurationProperties
- added unit test for EnumerateUnmanagedData
- added UnmanagedDataMappings section to serverconfig.ini

Modified: trunk/MgDev/Server/src/Core/serverconfig.ini
===================================================================
--- trunk/MgDev/Server/src/Core/serverconfig.ini	2007-01-29 19:29:09 UTC (rev 1079)
+++ trunk/MgDev/Server/src/Core/serverconfig.ini	2007-01-30 00:08:25 UTC (rev 1080)
@@ -438,3 +438,9 @@
 MS Pゴシック = MS PGothic
 MS 明朝 = MS Mincho
 MS P明朝 = MS PMincho
+
+[UnmanagedDataMappings]
+# *****************************************************************************
+# U N M A N A G E D  D A T A  M A P P I N G S
+# This section is used to map a mapping name to an unmanaged data folder.
+# *****************************************************************************
\ No newline at end of file

Modified: trunk/MgDev/Server/src/UnitTesting/TestResourceService.cpp
===================================================================
--- trunk/MgDev/Server/src/UnitTesting/TestResourceService.cpp	2007-01-29 19:29:09 UTC (rev 1079)
+++ trunk/MgDev/Server/src/UnitTesting/TestResourceService.cpp	2007-01-30 00:08:25 UTC (rev 1080)
@@ -1472,3 +1472,42 @@
         throw;
     }
 }
+
+///----------------------------------------------------------------------------
+/// Test Case Description:
+///
+/// This test case enumerates the unmanaged data
+///----------------------------------------------------------------------------
+void TestResourceService::TestCase_EnumerateUnmanagedData()
+{
+    try
+    {
+        MgServiceManager* serviceManager = MgServiceManager::GetInstance();
+        if(serviceManager == 0)
+        {
+            throw new MgNullReferenceException(L"TestResourceService.TestCase_EnumerateUnmanagedData", __LINE__, __WFILE__, NULL, L"", NULL);
+        }
+
+        Ptr<MgResourceService> pService = dynamic_cast<MgResourceService*>(serviceManager->RequestService(MgServiceType::ResourceService));
+        if (pService == 0)
+        {
+            throw new MgServiceNotAvailableException(L"TestResourceService.TestCase_EnumerateUnmanagedData", __LINE__, __WFILE__, NULL, L"", NULL);
+        }
+
+        // Try to enumerate mappings
+        Ptr<MgByteReader> byteReader0 = pService->EnumerateUnmanagedData(L"", false, L"FOLDERS", L"");
+        STRING mimeType0 = byteReader0->GetMimeType();
+        CPPUNIT_ASSERT(wcscmp(mimeType0.c_str(), MgMimeType::Xml.c_str()) == 0);
+
+        // Enumerate all unmanaged data files
+        Ptr<MgByteReader> byteReader1 = pService->EnumerateUnmanagedData(L"", true, L"FILES", L"");
+        STRING mimeType1 = byteReader1->GetMimeType();
+        CPPUNIT_ASSERT(wcscmp(mimeType1.c_str(), MgMimeType::Xml.c_str()) == 0);
+    }
+    catch(MgException* e)
+    {
+        STRING message = e->GetDetails(TEST_LOCALE);
+        SAFE_RELEASE(e);
+        CPPUNIT_FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
+    }
+}
\ No newline at end of file

Modified: trunk/MgDev/Server/src/UnitTesting/TestResourceService.h
===================================================================
--- trunk/MgDev/Server/src/UnitTesting/TestResourceService.h	2007-01-29 19:29:09 UTC (rev 1079)
+++ trunk/MgDev/Server/src/UnitTesting/TestResourceService.h	2007-01-30 00:08:25 UTC (rev 1080)
@@ -51,6 +51,8 @@
 
     CPPUNIT_TEST(TestCase_DeleteResource);
 
+    CPPUNIT_TEST(TestCase_EnumerateUnmanagedData);
+
     CPPUNIT_TEST(TestEnd); // This must be the very last unit test
     CPPUNIT_TEST_SUITE_END();
 
@@ -88,6 +90,8 @@
     void TestCase_DeleteResourceData();
 
     void TestCase_DeleteResource();
+
+    void TestCase_EnumerateUnmanagedData();
 };
 
 #endif // TESTRESOURCESERVICE_H_

Modified: trunk/MgDev/Server/src/UnitTesting/TestServerAdminService.cpp
===================================================================
--- trunk/MgDev/Server/src/UnitTesting/TestServerAdminService.cpp	2007-01-29 19:29:09 UTC (rev 1079)
+++ trunk/MgDev/Server/src/UnitTesting/TestServerAdminService.cpp	2007-01-30 00:08:25 UTC (rev 1080)
@@ -222,7 +222,57 @@
     }
 }
 
+///----------------------------------------------------------------------------
+/// Test Case Description:
+///
+/// This test case tries to remove the server configuration properties
+///----------------------------------------------------------------------------
+void TestServerAdminService::TestCase_RemoveConfigurationProperties()
+{
+    try
+    {
+        MgServiceManager* serviceMan = MgServiceManager::GetInstance();
+        if(serviceMan == 0)
+        {
+            throw new MgNullReferenceException(L"TestServerAdminService::TestCase_RemoveConfigurationProperties", __LINE__, __WFILE__, NULL, L"", NULL);
+        }
 
+        Ptr<MgServerAdminService> pService = dynamic_cast<MgServerAdminService*>(serviceMan->RequestService(MgServiceType::ServerAdminService));
+        if (pService == 0)
+        {
+            throw new MgServiceNotAvailableException(L"TestServerAdminService::TestCase_RemoveConfigurationProperties", __LINE__, __WFILE__, NULL, L"", NULL);
+        }
+
+        Ptr<MgPropertyCollection> pPropertyCollection1 = pService->GetConfigurationProperties(L"GeneralProperties");
+        Ptr<MgStringProperty> pProperty1 = (MgStringProperty*)pPropertyCollection1->GetItem(L"DefaultLocale");
+        STRING valueOriginal = pProperty1->GetValue();
+
+        Ptr<MgPropertyCollection> pPropertyCollectionRemove = new MgPropertyCollection();
+        Ptr<MgStringProperty> pPropertyRemove = new MgStringProperty(L"DefaultLocale", L"");
+        pPropertyCollectionRemove->Add(pPropertyRemove);
+
+        pService->RemoveConfigurationProperties(L"GeneralProperties", pPropertyCollectionRemove);
+
+        Ptr<MgPropertyCollection> pPropertyCollection2 = pService->GetConfigurationProperties(L"GeneralProperties");
+        Ptr<MgStringProperty> pProperty2 = (MgStringProperty*)pPropertyCollection1->GetItem(L"DefaultLocale");
+
+        CPPUNIT_ASSERT(pProperty2 == NULL);
+
+        // Restore original value
+        pService->SetConfigurationProperties(L"GeneralProperties", pPropertyCollection1);
+    }
+    catch(MgException* e)
+    {
+        STRING message = e->GetDetails(TEST_LOCALE);
+        SAFE_RELEASE(e);
+        CPPUNIT_FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
+    }
+    catch(...)
+    {
+        throw;
+    }
+}
+
 ///----------------------------------------------------------------------------
 /// Test Case Description:
 ///

Modified: trunk/MgDev/Server/src/UnitTesting/TestServerAdminService.h
===================================================================
--- trunk/MgDev/Server/src/UnitTesting/TestServerAdminService.h	2007-01-29 19:29:09 UTC (rev 1079)
+++ trunk/MgDev/Server/src/UnitTesting/TestServerAdminService.h	2007-01-30 00:08:25 UTC (rev 1080)
@@ -30,6 +30,7 @@
     //CPPUNIT_TEST(TestCase_IsOnline);
     CPPUNIT_TEST(TestCase_GetConfigurationProperties);
     CPPUNIT_TEST(TestCase_SetConfigurationProperties);
+    CPPUNIT_TEST(TestCase_RemoveConfigurationProperties);
     CPPUNIT_TEST(TestCase_GetInformationProperties);
 
     CPPUNIT_TEST(TestCase_ClearLog);
@@ -65,6 +66,7 @@
     //void TestCase_IsOnline();
     void TestCase_GetConfigurationProperties();
     void TestCase_SetConfigurationProperties();
+    void TestCase_RemoveConfigurationProperties();
     void TestCase_GetInformationProperties();
 
     void TestCase_ClearLog();



More information about the mapguide-commits mailing list