[mapguide-commits] r6874 - in trunk/MgDev/Desktop: MapViewer MgDesktop MgDesktop/Services MgDesktop/System UnitTest
svn_mapguide at osgeo.org
svn_mapguide at osgeo.org
Sat Jul 7 03:49:43 PDT 2012
Author: jng
Date: 2012-07-07 03:49:43 -0700 (Sat, 07 Jul 2012)
New Revision: 6874
Modified:
trunk/MgDev/Desktop/MapViewer/MgLegend.cs
trunk/MgDev/Desktop/MgDesktop/MgDesktop.vcproj
trunk/MgDev/Desktop/MgDesktop/MgDesktop.vcxproj
trunk/MgDev/Desktop/MgDesktop/Platform.ini
trunk/MgDev/Desktop/MgDesktop/Services/ResourceService.cpp
trunk/MgDev/Desktop/MgDesktop/Services/ResourceService.h
trunk/MgDev/Desktop/MgDesktop/Services/ServiceFactory.cpp
trunk/MgDev/Desktop/MgDesktop/Services/ServiceFactory.h
trunk/MgDev/Desktop/MgDesktop/System/PlatformInit.cpp
trunk/MgDev/Desktop/UnitTest/TestResourceService.cpp
trunk/MgDev/Desktop/UnitTest/TestResourceService.h
Log:
Merge r6857, r6860, r6861, r6873 to trunk
Modified: trunk/MgDev/Desktop/MapViewer/MgLegend.cs
===================================================================
--- trunk/MgDev/Desktop/MapViewer/MgLegend.cs 2012-07-07 05:30:18 UTC (rev 6873)
+++ trunk/MgDev/Desktop/MapViewer/MgLegend.cs 2012-07-07 10:49:43 UTC (rev 6874)
@@ -51,16 +51,33 @@
InitializeComponent();
}
+ private Dictionary<string, bool> _initialLayerSelectabilityState = new Dictionary<string, bool>();
+
internal void Init(MgMapViewerProvider provider)
{
_provider = provider;
_map = _provider.GetMap();
+ InitInitialSelectabilityStates();
_resSvc = (MgResourceService)_provider.CreateService(MgServiceType.ResourceService);
_selectableIcon = Properties.Resources.lc_select;
_unselectableIcon = Properties.Resources.lc_unselect;
RefreshLegend();
}
+ private void InitInitialSelectabilityStates()
+ {
+ if (_map != null)
+ {
+ _initialLayerSelectabilityState.Clear();
+ var layers = _map.GetLayers();
+ for (int i = 0; i < layers.GetCount(); i++)
+ {
+ var layer = layers.GetItem(i);
+ _initialLayerSelectabilityState[layer.GetObjectId()] = layer.Selectable;
+ }
+ }
+ }
+
private Dictionary<string, MgLayerBase> _layers = new Dictionary<string, MgLayerBase>();
private Dictionary<string, MgLayerGroup> _groups = new Dictionary<string, MgLayerGroup>();
private Dictionary<string, string> _layerDefinitionContents = new Dictionary<string, string>();
@@ -287,7 +304,9 @@
if (fsId.EndsWith("DrawingSource"))
{
node.SelectedImageKey = node.ImageKey = IMG_DWF;
- node.Tag = new LayerNodeMetadata(layer);
+ //If not in the dictionary, assume it is a dynamically added layer
+ bool bInitiallySelectable = _initialLayerSelectabilityState.ContainsKey(layer.GetObjectId()) ? _initialLayerSelectabilityState[layer.GetObjectId()] : layer.Selectable;
+ node.Tag = new LayerNodeMetadata(layer, bInitiallySelectable);
node.ToolTipText = string.Format(Properties.Resources.DrawingLayerTooltip, Environment.NewLine, layer.Name, layer.FeatureSourceId);
}
else
@@ -343,7 +362,9 @@
imgLegend.Images.Add(id, img);
node.SelectedImageKey = node.ImageKey = id;
- node.Tag = new LayerNodeMetadata(layer)
+ //If not in the dictionary, assume it is a dynamically added layer
+ bool bInitiallySelectable = _initialLayerSelectabilityState.ContainsKey(layer.GetObjectId()) ? _initialLayerSelectabilityState[layer.GetObjectId()] : layer.Selectable;
+ node.Tag = new LayerNodeMetadata(layer, bInitiallySelectable)
{
ThemeIcon = img
};
@@ -447,7 +468,7 @@
TreeNode node = new TreeNode();
node.Text = (count + " other styles");
node.ImageKey = node.SelectedImageKey = IMG_OTHER;
- node.Tag = new LayerNodeMetadata(null) {
+ node.Tag = new LayerNodeMetadata(null, false) {
IsBaseLayer = false,
ThemeIcon = Properties.Resources.icon_etc,
IsThemeRule = true
@@ -458,12 +479,12 @@
private TreeNode CreateThemeRuleNode(MgResourceIdentifier layerDefId, double viewScale, string labelText, int geomType, int categoryIndex)
{
MgByteReader icon = _provider.GenerateLegendImage(layerDefId,
- viewScale,
- 16,
- 16,
- "PNG",
- geomType,
- categoryIndex);
+ viewScale,
+ 16,
+ 16,
+ "PNG",
+ geomType,
+ categoryIndex);
TreeNode node = new TreeNode();
node.Text = labelText;
if (icon != null)
@@ -473,7 +494,7 @@
byte[] b = new byte[icon.GetLength()];
icon.Read(b, b.Length);
- var tag = new LayerNodeMetadata(null)
+ var tag = new LayerNodeMetadata(null, false)
{
IsBaseLayer = false,
IsThemeRule = true
@@ -535,12 +556,12 @@
class LayerNodeMetadata : LegendNodeMetadata
{
- public LayerNodeMetadata(MgLayerBase layer)
+ public LayerNodeMetadata(MgLayerBase layer, bool bInitiallySelectable)
{
base.IsGroup = false;
this.Layer = layer;
this.IsSelectable = (layer != null) ? layer.Selectable : false;
- this.DrawSelectabilityIcon = (layer != null);
+ this.DrawSelectabilityIcon = (layer != null && bInitiallySelectable);
this.IsThemeRule = false;
}
Modified: trunk/MgDev/Desktop/MgDesktop/MgDesktop.vcproj
===================================================================
--- trunk/MgDev/Desktop/MgDesktop/MgDesktop.vcproj 2012-07-07 05:30:18 UTC (rev 6873)
+++ trunk/MgDev/Desktop/MgDesktop/MgDesktop.vcproj 2012-07-07 10:49:43 UTC (rev 6874)
@@ -241,7 +241,7 @@
OutputFile="$(OutDir)\$(ProjectName).dll"
LinkIncremental="1"
AdditionalLibraryDirectories="..\..\Oem\ACE\ACE_wrappers\lib;..\..\Oem\FDO\Lib;..\..\Oem\DWFTK7.1\develop\global\lib\static\release\vc8.0;"..\..\Oem\dbxml\xerces-c-src\Build\Win32\VC9\Release";..\..\Common\lib\release;..\..\Server\lib\release"
- DelayLoadDLLs="MgMdfParser.dll;MgGeometry.dll;MgGwsCommon.dll;MgGwsResource.dll;xerces-c_3_1mg.dll;FDO.dll;FDOCommon.dll;MgStylization.dll;FDOGeometry.dll;ExpressionEngine.dll"
+ DelayLoadDLLs="MgMdfParser.dll;MgGeometry.dll;MgGwsCommon.dll;MgGwsResource.dll;FDO.dll;FDOCommon.dll;MgStylization.dll;FDOGeometry.dll;ExpressionEngine.dll"
GenerateDebugInformation="true"
SubSystem="2"
OptimizeReferences="2"
@@ -323,7 +323,7 @@
OutputFile="$(OutDir)\$(ProjectName).dll"
LinkIncremental="1"
AdditionalLibraryDirectories="..\..\Oem\ACE\ACE_wrappers\lib64;..\..\Oem\FDO\Lib64;..\..\Oem\DWFTK7.1\develop\global\lib\static\release64\vc8.0;"..\..\Oem\dbxml\xerces-c-src\Build\x64\VC9\Release";..\..\Common\lib\release64;..\..\Server\lib\release64"
- DelayLoadDLLs="MgMdfParser.dll;MgGeometry.dll;MgGwsCommon.dll;MgGwsResource.dll;xerces-c_3_1mg.dll;FDO.dll;FDOCommon.dll;MgStylization.dll;FDOGeometry.dll;ExpressionEngine.dll"
+ DelayLoadDLLs="MgMdfParser.dll;MgGeometry.dll;MgGwsCommon.dll;MgGwsResource.dll;FDO.dll;FDOCommon.dll;MgStylization.dll;FDOGeometry.dll;ExpressionEngine.dll"
GenerateDebugInformation="true"
SubSystem="2"
OptimizeReferences="2"
Modified: trunk/MgDev/Desktop/MgDesktop/MgDesktop.vcxproj
===================================================================
--- trunk/MgDev/Desktop/MgDesktop/MgDesktop.vcxproj 2012-07-07 05:30:18 UTC (rev 6873)
+++ trunk/MgDev/Desktop/MgDesktop/MgDesktop.vcxproj 2012-07-07 10:49:43 UTC (rev 6874)
@@ -129,7 +129,7 @@
<AdditionalDependencies>FDO.lib;FDOCommon.lib;FDOGeometry.lib;ExpressionEngine.lib;ACE.lib;MgFoundation.lib;MgGeometry.lib;MgMdfModel.lib;MgMdfParser.lib;MgPlatformBase.lib;MgRenderers.lib;MgStylization.lib;MgGwsCommon.lib;MgGwsQueryEngine.lib;xerces-c_3mg.lib;dwfcore_wt.1.1.1.lib;dwftk_wt.7.1.1.lib;whiptk_wt.7.7.601.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>$(OutDir)$(ProjectName).dll</OutputFile>
<AdditionalLibraryDirectories>..\..\Oem\ACE\ACE_wrappers\lib;..\..\Oem\FDO\Lib;..\..\Oem\DWFTK7.1\develop\global\lib\static\release\vc8.0;..\..\Oem\dbxml\xerces-c-src\Build\Win32\VC10\Release;..\..\Common\lib\release;..\..\Server\lib\release;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
- <DelayLoadDLLs>MgMdfParser.dll;MgGeometry.dll;MgGwsCommon.dll;MgGwsResource.dll;xerces-c_3_1mg.dll;FDO.dll;FDOCommon.dll;MgStylization.dll;FDOGeometry.dll;ExpressionEngine.dll;%(DelayLoadDLLs)</DelayLoadDLLs>
+ <DelayLoadDLLs>MgMdfParser.dll;MgGeometry.dll;MgGwsCommon.dll;MgGwsResource.dll;FDO.dll;FDOCommon.dll;MgStylization.dll;FDOGeometry.dll;ExpressionEngine.dll;%(DelayLoadDLLs)</DelayLoadDLLs>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Windows</SubSystem>
<OptimizeReferences>true</OptimizeReferences>
@@ -205,7 +205,7 @@
<AdditionalDependencies>FDO.lib;FDOCommon.lib;FDOGeometry.lib;ExpressionEngine.lib;ACE.lib;MgFoundation.lib;MgGeometry.lib;MgMdfModel.lib;MgMdfParser.lib;MgPlatformBase.lib;MgRenderers.lib;MgStylization.lib;MgGwsCommon.lib;MgGwsQueryEngine.lib;xerces-c_3mg.lib;dwfcore_wt.1.1.1.lib;dwftk_wt.7.1.1.lib;whiptk_wt.7.7.601.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>$(OutDir)$(ProjectName).dll</OutputFile>
<AdditionalLibraryDirectories>..\..\Oem\ACE\ACE_wrappers\lib64;..\..\Oem\FDO\Lib64;..\..\Oem\DWFTK7.1\develop\global\lib\static\release64\vc8.0;..\..\Oem\dbxml\xerces-c-src\Build\x64\VC10\Release;..\..\Common\lib\release64;..\..\Server\lib\release64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
- <DelayLoadDLLs>MgMdfParser.dll;MgGeometry.dll;MgGwsCommon.dll;MgGwsResource.dll;xerces-c_3_1mg.dll;FDO.dll;FDOCommon.dll;MgStylization.dll;FDOGeometry.dll;ExpressionEngine.dll;%(DelayLoadDLLs)</DelayLoadDLLs>
+ <DelayLoadDLLs>MgMdfParser.dll;MgGeometry.dll;MgGwsCommon.dll;MgGwsResource.dll;FDO.dll;FDOCommon.dll;MgStylization.dll;FDOGeometry.dll;ExpressionEngine.dll;%(DelayLoadDLLs)</DelayLoadDLLs>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Windows</SubSystem>
<OptimizeReferences>true</OptimizeReferences>
Modified: trunk/MgDev/Desktop/MgDesktop/Platform.ini
===================================================================
(Binary files differ)
Modified: trunk/MgDev/Desktop/MgDesktop/Services/ResourceService.cpp
===================================================================
--- trunk/MgDev/Desktop/MgDesktop/Services/ResourceService.cpp 2012-07-07 05:30:18 UTC (rev 6873)
+++ trunk/MgDev/Desktop/MgDesktop/Services/ResourceService.cpp 2012-07-07 10:49:43 UTC (rev 6874)
@@ -19,13 +19,14 @@
}
//INTERNAL_API:
-MgdResourceService::MgdResourceService(CREFSTRING libraryContentRoot, CREFSTRING libraryDataRoot, CREFSTRING sessionContentRoot, CREFSTRING sessionDataRoot)
+MgdResourceService::MgdResourceService(CREFSTRING libraryContentRoot, CREFSTRING libraryDataRoot, CREFSTRING sessionContentRoot, CREFSTRING sessionDataRoot, CREFSTRING schemaPath)
: MgResourceService()
{
m_libraryContentPath = libraryContentRoot;
m_libraryDataPath = libraryDataRoot;
m_sessionContentPath = sessionContentRoot;
m_sessionDataPath = sessionDataRoot;
+ m_schemaPath = schemaPath;
}
MgdResourceService::~MgdResourceService() { }
@@ -298,7 +299,95 @@
if (NULL != content)
{
Ptr<MgByteSink> sink = new MgByteSink(content);
- sink->ToFile(path);
+
+ std::string xml;
+ sink->ToStringUtf8(xml);
+
+ XercesDOMParser parser;
+ parser.setValidationScheme(XercesDOMParser::Val_Always);
+ parser.cacheGrammarFromParse(true);
+ DefaultHandler handler;
+ parser.setErrorHandler(&handler);
+ try
+ {
+ MemBufInputSource source((const XMLByte*)xml.c_str(), xml.size(), "MgdResourceService.Class", false);
+ parser.parse(source);
+
+ DOMDocument* doc = parser.getDocument();
+ CHECKNULL(doc, L"MgdResourceService::SetResource");
+ STRING resType = resource->GetResourceType();
+ DOMElement* docEl = doc->getDocumentElement();
+ CHECKNULL(docEl, L"MgdResourceService::SetResource");
+ STRING docElName = docEl->getNodeName();
+
+ //Now make sure it's the right type of XML document
+
+ //Everything except SymbolDefinitions will have the same root element name as the resource type
+ if (resType != MgResourceType::SymbolDefinition)
+ {
+ if (resType != docElName)
+ {
+ MgStringCollection args;
+ args.Add(docElName);
+ throw new MgInvalidResourceTypeException(L"MgdResourceService::SetResource", __LINE__, __WFILE__, &args, L"", NULL);
+ }
+ }
+ else
+ {
+ if (docElName != L"SimpleSymbolDefinition" && docElName != L"CompoundSymbolDefinition")
+ {
+ MgStringCollection args;
+ args.Add(docElName);
+ throw new MgInvalidResourceTypeException(L"MgdResourceService::SetResource", __LINE__, __WFILE__, &args, L"", NULL);
+ }
+ }
+ }
+ catch (const SAXParseException& e)
+ {
+ STRING msg = e.getMessage();
+ XMLFileLoc lineNum = e.getLineNumber();
+ XMLFileLoc colNum = e.getColumnNumber();
+
+ const XMLCh* pubId = e.getPublicId();
+ const XMLCh* sysId = e.getSystemId();
+
+ STRING pubIdStr;
+ if (NULL != pubId)
+ pubIdStr = pubId;
+ STRING sysIdStr;
+ if (NULL != sysId)
+ sysIdStr = sysId;
+
+ STRING lineNumStr;
+ STRING colNumStr;
+ MgUtil::Int64ToString(lineNum, lineNumStr);
+ MgUtil::Int64ToString(colNum, colNumStr);
+
+ MgStringCollection args;
+ args.Add(msg);
+ args.Add(lineNumStr);
+ args.Add(colNumStr);
+ args.Add(pubIdStr);
+ args.Add(sysIdStr);
+ throw new MgXmlParserException(L"MgdResourceService::SetResource", __LINE__, __WFILE__, &args, L"", NULL);
+ }
+
+ //Can't rewind a byte sink. So make another one
+ if (content->IsRewindable())
+ {
+ content->Rewind();
+ Ptr<MgByteSink> sink2 = new MgByteSink(content);
+ sink2->ToFile(path);
+ }
+ else
+ {
+ //Make a new byte source/reader/sink from the checked out xml string
+ Ptr<MgByteSource> bs = new MgByteSource((BYTE_ARRAY_IN)xml.c_str(), (INT32)xml.length());
+ Ptr<MgByteReader> rdr = bs->GetReader();
+ Ptr<MgByteSink> sink2 = new MgByteSink(rdr);
+ sink2->ToFile(path);
+ }
+
ReleasePotentialLocks(resource);
}
Modified: trunk/MgDev/Desktop/MgDesktop/Services/ResourceService.h
===================================================================
--- trunk/MgDev/Desktop/MgDesktop/Services/ResourceService.h 2012-07-07 05:30:18 UTC (rev 6873)
+++ trunk/MgDev/Desktop/MgDesktop/Services/ResourceService.h 2012-07-07 10:49:43 UTC (rev 6874)
@@ -8,7 +8,7 @@
DECLARE_CLASSNAME(MgdResourceService)
INTERNAL_API:
- MgdResourceService(CREFSTRING libraryContentRoot, CREFSTRING libraryDataRoot, CREFSTRING sessionContentRoot, CREFSTRING sessionDataRoot);
+ MgdResourceService(CREFSTRING libraryContentRoot, CREFSTRING libraryDataRoot, CREFSTRING sessionContentRoot, CREFSTRING sessionDataRoot, CREFSTRING schemaPath);
virtual MgByteReader* EnumerateRepositories(CREFSTRING repositoryType);
Modified: trunk/MgDev/Desktop/MgDesktop/Services/ServiceFactory.cpp
===================================================================
--- trunk/MgDev/Desktop/MgDesktop/Services/ServiceFactory.cpp 2012-07-07 05:30:18 UTC (rev 6873)
+++ trunk/MgDev/Desktop/MgDesktop/Services/ServiceFactory.cpp 2012-07-07 10:49:43 UTC (rev 6874)
@@ -11,6 +11,7 @@
STRING MgServiceFactory::sm_libDataPath = L"";
STRING MgServiceFactory::sm_sesContentPath = L"";
STRING MgServiceFactory::sm_sesDataPath = L"";
+STRING MgServiceFactory::sm_schemaPath = L"";
MG_IMPL_DYNCREATE(MgServiceFactory);
@@ -42,6 +43,11 @@
sm_sesDataPath,
MgConfigProperties::DefaultResourceServicePropertySessionResourceDataFilePath);
+ conf->GetStringValue(MgConfigProperties::ResourceServicePropertiesSection,
+ MgConfigProperties::ResourceServicePropertyResourceSchemaFilePath,
+ sm_schemaPath,
+ MgConfigProperties::DefaultResourceServicePropertyResourceSchemaFilePath);
+
//Create these paths if they don't exist
if (!MgFileUtil::IsDirectory(sm_libContentPath))
MgFileUtil::CreateDirectory(sm_libContentPath, false, true);
@@ -51,6 +57,12 @@
MgFileUtil::CreateDirectory(sm_sesContentPath, false, true);
if (!MgFileUtil::IsDirectory(sm_sesDataPath))
MgFileUtil::CreateDirectory(sm_sesDataPath, false, true);
+ if (!MgFileUtil::IsDirectory(sm_schemaPath))
+ {
+ MgStringCollection args;
+ args.Add(sm_schemaPath);
+ throw new MgDirectoryNotFoundException(L"MgServiceFactory::Initialize", __LINE__, __WFILE__, &args, L"", NULL);
+ }
}
MgService* MgServiceFactory::CreateService(INT32 serviceType)
@@ -71,7 +83,8 @@
return new MgdResourceService(sm_libContentPath,
sm_libDataPath,
sm_sesContentPath,
- sm_sesDataPath);
+ sm_sesDataPath,
+ sm_schemaPath);
case MgServiceType::TileService:
return new MgdTileService();
}
Modified: trunk/MgDev/Desktop/MgDesktop/Services/ServiceFactory.h
===================================================================
--- trunk/MgDev/Desktop/MgDesktop/Services/ServiceFactory.h 2012-07-07 05:30:18 UTC (rev 6873)
+++ trunk/MgDev/Desktop/MgDesktop/Services/ServiceFactory.h 2012-07-07 10:49:43 UTC (rev 6874)
@@ -34,6 +34,7 @@
static STRING sm_libDataPath;
static STRING sm_sesContentPath;
static STRING sm_sesDataPath;
+ static STRING sm_schemaPath;
};
#endif
\ No newline at end of file
Modified: trunk/MgDev/Desktop/MgDesktop/System/PlatformInit.cpp
===================================================================
--- trunk/MgDev/Desktop/MgDesktop/System/PlatformInit.cpp 2012-07-07 05:30:18 UTC (rev 6873)
+++ trunk/MgDev/Desktop/MgDesktop/System/PlatformInit.cpp 2012-07-07 10:49:43 UTC (rev 6874)
@@ -14,6 +14,7 @@
return;
ACE::init();
+ XMLPlatformUtils::Initialize();
MgConfiguration* pConfiguration = MgConfiguration::GetInstance();
pConfiguration->LoadConfiguration(configFile);
@@ -179,6 +180,7 @@
Ptr<MgdResourceService> resSvc = dynamic_cast<MgdResourceService*>(fact->CreateService(MgServiceType::ResourceService));
resSvc->DeleteSessionFiles();
+ XMLPlatformUtils::Terminate();
ACE::fini();
MG_CATCH_AND_RELEASE()
Modified: trunk/MgDev/Desktop/UnitTest/TestResourceService.cpp
===================================================================
--- trunk/MgDev/Desktop/UnitTest/TestResourceService.cpp 2012-07-07 05:30:18 UTC (rev 6873)
+++ trunk/MgDev/Desktop/UnitTest/TestResourceService.cpp 2012-07-07 10:49:43 UTC (rev 6874)
@@ -429,6 +429,77 @@
}
}
+void TestResourceService::TestCase_SetResourceInvalid()
+{
+ try
+ {
+ Ptr<MgServiceFactory> fact = new MgServiceFactory();
+ Ptr<MgResourceService> pService = dynamic_cast<MgResourceService*>(fact->CreateService(MgServiceType::ResourceService));
+ if (pService == 0)
+ {
+ throw new MgServiceNotAvailableException(L"TestResourceService.TestCase_MoveResource", __LINE__, __WFILE__, NULL, L"", NULL);
+ }
+
+ std::string notXml = "Not XML content";
+ std::string malformedXml = "<Foo></Bar>";
+ std::string fsXml = "<FeatureSource></FeatureSource>";
+ std::string unkXml = "<Unknown></Unknown>";
+ std::string fsIncompleteXml = "<FeatureSource xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xsi:noNamespaceSchemaLocation=\"FeatureSource-1.0.0.xsd\"></FeatureSource>";
+ std::string simpleSymXml = "<SimpleSymbolDefinition></SimpleSymbolDefinition>";
+ std::string compoundSymXml = "<CompoundSymbolDefinition></CompoundSymbolDefinition>";
+
+ Ptr<MgByteSource> bs1 = new MgByteSource((BYTE_ARRAY_IN)notXml.c_str(), (INT32)notXml.length());
+ Ptr<MgByteSource> bs2 = new MgByteSource((BYTE_ARRAY_IN)malformedXml.c_str(), (INT32)malformedXml.length());
+ Ptr<MgByteSource> bs3 = new MgByteSource((BYTE_ARRAY_IN)fsXml.c_str(), (INT32)fsXml.length());
+ Ptr<MgByteSource> bs4 = new MgByteSource((BYTE_ARRAY_IN)unkXml.c_str(), (INT32)unkXml.length());
+ Ptr<MgByteSource> bs5 = new MgByteSource((BYTE_ARRAY_IN)fsIncompleteXml.c_str(), (INT32)fsIncompleteXml.length());
+ Ptr<MgByteSource> bs6 = new MgByteSource((BYTE_ARRAY_IN)simpleSymXml.c_str(), (INT32)simpleSymXml.length());
+ Ptr<MgByteSource> bs7 = new MgByteSource((BYTE_ARRAY_IN)compoundSymXml.c_str(), (INT32)compoundSymXml.length());
+
+ Ptr<MgByteReader> r1 = bs1->GetReader();
+ Ptr<MgByteReader> r2 = bs2->GetReader();
+ Ptr<MgByteReader> r3 = bs3->GetReader();
+ Ptr<MgByteReader> r4 = bs4->GetReader();
+ Ptr<MgByteReader> r5 = bs5->GetReader();
+ Ptr<MgByteReader> r6 = bs6->GetReader();
+ Ptr<MgByteReader> r7 = bs7->GetReader();
+ Ptr<MgResourceIdentifier> resId = new MgResourceIdentifier(L"Library://UnitTests/NotGettingSaved.FeatureSource");
+ Ptr<MgResourceIdentifier> ldfId = new MgResourceIdentifier(L"Library://UnitTests/NotGettingSaved.LayerDefinition");
+ Ptr<MgResourceIdentifier> mdfId = new MgResourceIdentifier(L"Library://UnitTests/NotGettingSaved.MapDefinition");
+ Ptr<MgResourceIdentifier> pltId = new MgResourceIdentifier(L"Library://UnitTests/NotGettingSaved.PrintLayout");
+ Ptr<MgResourceIdentifier> symId = new MgResourceIdentifier(L"Library://UnitTests/NotGettingSaved.SymbolDefinition");
+ Ptr<MgResourceIdentifier> slbId = new MgResourceIdentifier(L"Library://UnitTests/NotGettingSaved.SymbolLibrary");
+ Ptr<MgResourceIdentifier> ssId = new MgResourceIdentifier(L"Library://UnitTests/GettingSavedSimple.SymbolDefinition");
+ Ptr<MgResourceIdentifier> csId = new MgResourceIdentifier(L"Library://UnitTests/GettingSavedCompound.SymbolDefinition");
+
+ //TODO: We can get xerces to vet the content as being XML, but can't figure out how to get xerces
+ //to validate the content model. Until we figure that out, the relevant assertions are commented
+ //out. Still at this stage it's better than letting any arbitrary content get through these calls.
+ CPPUNIT_ASSERT_THROW_MG(pService->SetResource(resId, r1, NULL), MgXmlParserException*);
+ CPPUNIT_ASSERT_THROW_MG(pService->SetResource(resId, r2, NULL), MgXmlParserException*);
+ //CPPUNIT_ASSERT_THROW_MG(pService->SetResource(resId, r3, NULL), MgXmlParserException*);
+ CPPUNIT_ASSERT_THROW_MG(pService->SetResource(ldfId, r3, NULL), MgInvalidResourceTypeException*);
+ r3->Rewind();
+ CPPUNIT_ASSERT_THROW_MG(pService->SetResource(mdfId, r3, NULL), MgInvalidResourceTypeException*);
+ r3->Rewind();
+ CPPUNIT_ASSERT_THROW_MG(pService->SetResource(pltId, r3, NULL), MgInvalidResourceTypeException*);
+ r3->Rewind();
+ CPPUNIT_ASSERT_THROW_MG(pService->SetResource(symId, r3, NULL), MgInvalidResourceTypeException*);
+ r3->Rewind();
+ CPPUNIT_ASSERT_THROW_MG(pService->SetResource(slbId, r3, NULL), MgInvalidResourceTypeException*);
+ CPPUNIT_ASSERT_THROW_MG(pService->SetResource(resId, r4, NULL), MgInvalidResourceTypeException*);
+ //CPPUNIT_ASSERT_THROW_MG(pService->SetResource(resId, r5, NULL), MgXmlParserException*);
+ pService->SetResource(ssId, r6, NULL);
+ pService->SetResource(csId, r7, NULL);
+ }
+ catch(MgException* e)
+ {
+ STRING message = e->GetDetails(TEST_LOCALE);
+ SAFE_RELEASE(e);
+ CPPUNIT_FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
+ }
+}
+
///----------------------------------------------------------------------------
/// Test Case Description:
///
Modified: trunk/MgDev/Desktop/UnitTest/TestResourceService.h
===================================================================
--- trunk/MgDev/Desktop/UnitTest/TestResourceService.h 2012-07-07 05:30:18 UTC (rev 6873)
+++ trunk/MgDev/Desktop/UnitTest/TestResourceService.h 2012-07-07 10:49:43 UTC (rev 6874)
@@ -36,6 +36,7 @@
CPPUNIT_TEST(TestCase_ResourceExists);
CPPUNIT_TEST(TestCase_EnumerateResources);
CPPUNIT_TEST(TestCase_SetResource);
+ CPPUNIT_TEST(TestCase_SetResourceInvalid);
CPPUNIT_TEST(TestCase_MoveResource);
CPPUNIT_TEST(TestCase_CopyResource);
CPPUNIT_TEST(TestCase_GetResourceContent);
@@ -78,6 +79,7 @@
void TestCase_ResourceExists();
void TestCase_EnumerateResources();
void TestCase_SetResource();
+ void TestCase_SetResourceInvalid();
void TestCase_MoveResource();
void TestCase_CopyResource();
void TestCase_GetResourceContent();
More information about the mapguide-commits
mailing list