[mapguide-commits] r1373 - in trunk/MgDev:
Common/MapGuideCommon/MapLayer Server/src/UnitTesting
svn_mapguide at osgeo.org
svn_mapguide at osgeo.org
Mon Mar 26 01:50:46 EDT 2007
Author: stevedang
Date: 2007-03-26 01:50:01 -0400 (Mon, 26 Mar 2007)
New Revision: 1373
Modified:
trunk/MgDev/Common/MapGuideCommon/MapLayer/Map.cpp
trunk/MgDev/Server/src/UnitTesting/TestKmlService.cpp
trunk/MgDev/Server/src/UnitTesting/TestMappingService.cpp
trunk/MgDev/Server/src/UnitTesting/TestMappingService.h
trunk/MgDev/Server/src/UnitTesting/TestRenderingService.cpp
trunk/MgDev/Server/src/UnitTesting/TestTileService.cpp
Log:
Add some RFC 9 unit tests.
Modified: trunk/MgDev/Common/MapGuideCommon/MapLayer/Map.cpp
===================================================================
--- trunk/MgDev/Common/MapGuideCommon/MapLayer/Map.cpp 2007-03-25 21:27:33 UTC (rev 1372)
+++ trunk/MgDev/Common/MapGuideCommon/MapLayer/Map.cpp 2007-03-26 05:50:01 UTC (rev 1373)
@@ -115,8 +115,7 @@
InitializeResourceService(resourceService);
m_trackChangesDisabled = true;
- m_mapDefinitionId = mapDefinition;
- SAFE_ADDREF((MgResourceIdentifier*)m_mapDefinitionId);
+ m_mapDefinitionId = SAFE_ADDREF(mapDefinition);
m_name = mapName;
//Generate a unique id for this map
@@ -402,6 +401,7 @@
//
void MgMap::Create(CREFSTRING mapSRS, MgEnvelope* mapExtent, CREFSTRING mapName)
{
+ m_name = mapName;
MgMapBase::Create(mapSRS, mapExtent, mapName);
m_unpackedLayersGroups = true;
}
@@ -418,10 +418,19 @@
m_trackChangesDisabled = true;
STRING sessionId;
- Ptr<MgUserInformation> userInfo = m_resourceService->GetUserInfo();
+ Ptr<MgUserInformation> userInfo;
- if (userInfo.p != NULL)
+ if (NULL == m_siteConnection.p)
{
+ userInfo = m_resourceService->GetUserInfo();
+ }
+ else
+ {
+ userInfo = m_siteConnection->GetUserInfo();
+ }
+
+ if (NULL != userInfo.p)
+ {
sessionId = userInfo->GetMgSessionId();
}
@@ -436,6 +445,8 @@
}
Ptr<MgResourceIdentifier> resId = new MgResourceIdentifier(L"Session:" + sessionId + L"//" + mapName + L"." + MgResourceType::Map);
+
+ m_name = mapName;
MgResource::Open(m_resourceService, resId);
//Note: Layers and Groups are loaded on demand by UnpackLayersAndGroups
@@ -464,8 +475,11 @@
InitializeResourceService(resourceService);
- if(m_resId == (MgResourceIdentifier*)NULL)
- throw new MgNullReferenceException(L"MgMap.Save", __LINE__, __WFILE__, NULL, L"", NULL);
+ if (NULL == m_resId.p)
+ {
+ throw new MgNullReferenceException(L"MgMap.Save",
+ __LINE__, __WFILE__, NULL, L"", NULL);
+ }
m_inSave = true;
@@ -502,9 +516,13 @@
InitializeResourceService(resourceService);
m_resId = SAFE_ADDREF(resourceId);
- if(m_resId == (MgResourceIdentifier*)NULL)
- throw new MgNullReferenceException(L"MgMap.Save", __LINE__, __WFILE__, NULL, L"", NULL);
+ if (NULL == m_resId.p)
+ {
+ throw new MgNullReferenceException(L"MgMap.Save",
+ __LINE__, __WFILE__, NULL, L"", NULL);
+ }
+
m_inSave = true;
SerializeToRepository(m_resourceService, true);
@@ -534,7 +552,27 @@
///
void MgMap::Save()
{
- Save(NULL);
+ if (NULL == m_resId.p)
+ {
+ if (NULL == m_siteConnection.p || m_name.empty())
+ {
+ throw new MgNullReferenceException(L"MgMap.Save",
+ __LINE__, __WFILE__, NULL, L"", NULL);
+ }
+ else
+ {
+ Ptr<MgUserInformation> userInfo = m_siteConnection->GetUserInfo();
+ STRING sessionId = userInfo->GetMgSessionId();
+ Ptr<MgResourceIdentifier> resId = new MgResourceIdentifier(
+ L"Session:" + sessionId + L"//" + m_name + L"." + MgResourceType::Map);
+
+ Save(NULL, resId);
+ }
+ }
+ else
+ {
+ Save(NULL);
+ }
}
//////////////////////////////////////////////////////////////
Modified: trunk/MgDev/Server/src/UnitTesting/TestKmlService.cpp
===================================================================
--- trunk/MgDev/Server/src/UnitTesting/TestKmlService.cpp 2007-03-25 21:27:33 UTC (rev 1372)
+++ trunk/MgDev/Server/src/UnitTesting/TestKmlService.cpp 2007-03-26 05:50:01 UTC (rev 1373)
@@ -88,6 +88,11 @@
}
#endif
+ //set user info
+ Ptr<MgUserInformation> userInfo = new MgUserInformation(L"Administrator", L"admin");
+ userInfo->SetLocale(TEST_LOCALE);
+ MgUserInformation::SetCurrentUserInfo(userInfo);
+
//publish the map definition
Ptr<MgResourceIdentifier> mapres = new MgResourceIdentifier(L"Library://UnitTests/Maps/Sheboygan.MapDefinition");
Ptr<MgByteSource> mdfsrc = new MgByteSource(L"../UnitTestFiles/UT_Sheboygan.mdf", false);
@@ -156,6 +161,11 @@
{
try
{
+ //set user info
+ Ptr<MgUserInformation> userInfo = new MgUserInformation(L"Administrator", L"admin");
+ userInfo->SetLocale(TEST_LOCALE);
+ MgUserInformation::SetCurrentUserInfo(userInfo);
+
//delete the map definition
Ptr<MgResourceIdentifier> mapres = new MgResourceIdentifier(L"Library://UnitTests/Maps/Sheboygan.MapDefinition");
m_svcResource->DeleteResource(mapres);
Modified: trunk/MgDev/Server/src/UnitTesting/TestMappingService.cpp
===================================================================
--- trunk/MgDev/Server/src/UnitTesting/TestMappingService.cpp 2007-03-25 21:27:33 UTC (rev 1372)
+++ trunk/MgDev/Server/src/UnitTesting/TestMappingService.cpp 2007-03-26 05:50:01 UTC (rev 1373)
@@ -22,6 +22,7 @@
#include "ServerMappingService.h"
#include "ServerSiteService.h"
#include "../Common/Manager/FdoConnectionManager.h"
+#include "CppUnitExtensions.h"
const STRING TEST_LOCALE = L"en";
@@ -302,7 +303,34 @@
}
}
+void TestMappingService::TestCase_SaveMap()
+{
+ try
+ {
+ // Create a runtime map, save it, then open it.
+ Ptr<MgResourceIdentifier> mapDefId = new MgResourceIdentifier(L"Library://UnitTests/Maps/Sheboygan.MapDefinition");
+ STRING mapName = L"UnitTestSheboygan";
+ Ptr<MgMap> map = new MgMap(m_siteConnection);
+ map->Create(mapDefId, mapName);
+ map->Save();
+ map->Open(mapName);
+
+ Ptr<MgLayerCollection> layers = map->GetLayers();
+ assert(layers->GetCount() > 0);
+ }
+ catch (MgException* e)
+ {
+ STRING message = e->GetDetails(TEST_LOCALE);
+ SAFE_RELEASE(e);
+ CPPUNIT_FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
+ }
+ catch (...)
+ {
+ throw;
+ }
+}
+
void TestMappingService::TestCase_GetMultiPlot()
{
try
Modified: trunk/MgDev/Server/src/UnitTesting/TestMappingService.h
===================================================================
--- trunk/MgDev/Server/src/UnitTesting/TestMappingService.h 2007-03-25 21:27:33 UTC (rev 1372)
+++ trunk/MgDev/Server/src/UnitTesting/TestMappingService.h 2007-03-26 05:50:01 UTC (rev 1373)
@@ -27,6 +27,7 @@
CPPUNIT_TEST(TestCase_GetMap);
CPPUNIT_TEST(TestCase_GetMapUpdate);
+ CPPUNIT_TEST(TestCase_SaveMap);
CPPUNIT_TEST(TestCase_GetMultiPlot);
CPPUNIT_TEST(TestCase_GetPlotUsingCurrentCenterAndScale);
CPPUNIT_TEST(TestCase_GetPlotUsingOverriddenCenterAndScale);
@@ -50,6 +51,7 @@
void TestCase_GetMap();
void TestCase_GetMapUpdate();
+ void TestCase_SaveMap();
void TestCase_GetPlot();
void TestCase_GetMultiPlot();
void TestCase_GetPlotUsingCurrentCenterAndScale();
Modified: trunk/MgDev/Server/src/UnitTesting/TestRenderingService.cpp
===================================================================
--- trunk/MgDev/Server/src/UnitTesting/TestRenderingService.cpp 2007-03-25 21:27:33 UTC (rev 1372)
+++ trunk/MgDev/Server/src/UnitTesting/TestRenderingService.cpp 2007-03-26 05:50:01 UTC (rev 1373)
@@ -88,6 +88,11 @@
}
#endif
+ // set user info
+ Ptr<MgUserInformation> userInfo = new MgUserInformation(L"Administrator", L"admin");
+ userInfo->SetLocale(TEST_LOCALE);
+ MgUserInformation::SetCurrentUserInfo(userInfo);
+
// publish the map definition
Ptr<MgResourceIdentifier> mapres1 = new MgResourceIdentifier(L"Library://UnitTests/Maps/Sheboygan.MapDefinition");
Ptr<MgByteSource> mdfsrc1 = new MgByteSource(L"../UnitTestFiles/UT_Sheboygan.mdf", false);
@@ -284,6 +289,11 @@
{
try
{
+ // set user info
+ Ptr<MgUserInformation> userInfo = new MgUserInformation(L"Administrator", L"admin");
+ userInfo->SetLocale(TEST_LOCALE);
+ MgUserInformation::SetCurrentUserInfo(userInfo);
+
// delete the map definition
Ptr<MgResourceIdentifier> mapres1 = new MgResourceIdentifier(L"Library://UnitTests/Maps/Sheboygan.MapDefinition");
m_svcResource->DeleteResource(mapres1);
Modified: trunk/MgDev/Server/src/UnitTesting/TestTileService.cpp
===================================================================
--- trunk/MgDev/Server/src/UnitTesting/TestTileService.cpp 2007-03-25 21:27:33 UTC (rev 1372)
+++ trunk/MgDev/Server/src/UnitTesting/TestTileService.cpp 2007-03-26 05:50:01 UTC (rev 1373)
@@ -94,6 +94,11 @@
}
#endif
+ // set user info
+ Ptr<MgUserInformation> userInfo = new MgUserInformation(L"Administrator", L"admin");
+ userInfo->SetLocale(TEST_LOCALE);
+ MgUserInformation::SetCurrentUserInfo(userInfo);
+
// ------------------------------------------------------
// base map source data
// ------------------------------------------------------
@@ -169,6 +174,11 @@
{
try
{
+ // set user info
+ Ptr<MgUserInformation> userInfo = new MgUserInformation(L"Administrator", L"admin");
+ userInfo->SetLocale(TEST_LOCALE);
+ MgUserInformation::SetCurrentUserInfo(userInfo);
+
// ------------------------------------------------------
// base map source data
// ------------------------------------------------------
More information about the mapguide-commits
mailing list