[mapguide-commits] r6715 - in trunk/MgDev: Common/Foundation/Data Common/Foundation/System Common/MapGuideCommon/Resources Common/PlatformBase/Services Server Server/src/Common/Manager Server/src/Services/Feature Server/src/UnitTesting

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Thu May 31 06:01:34 PDT 2012


Author: jng
Date: 2012-05-31 06:01:33 -0700 (Thu, 31 May 2012)
New Revision: 6715

Added:
   trunk/MgDev/Server/src/UnitTesting/TestMisc.cpp
   trunk/MgDev/Server/src/UnitTesting/TestMisc.h
Modified:
   trunk/MgDev/Common/Foundation/Data/NamedCollection.cpp
   trunk/MgDev/Common/Foundation/System/Util.h
   trunk/MgDev/Common/MapGuideCommon/Resources/mapguide_en.res
   trunk/MgDev/Common/PlatformBase/Services/FeatureReader.cpp
   trunk/MgDev/Server/Server_VS2010.sln
   trunk/MgDev/Server/src/Common/Manager/FdoConnectionManager.cpp
   trunk/MgDev/Server/src/Common/Manager/FdoConnectionManager.h
   trunk/MgDev/Server/src/Services/Feature/ServerDescribeSchema.cpp
   trunk/MgDev/Server/src/Services/Feature/ServerFeatureService.cpp
   trunk/MgDev/Server/src/Services/Feature/ServerFeatureServiceExceptionDef.h
   trunk/MgDev/Server/src/UnitTesting/UnitTesting.cpp
   trunk/MgDev/Server/src/UnitTesting/UnitTesting.vcproj
   trunk/MgDev/Server/src/UnitTesting/UnitTesting.vcxproj
Log:
Merge in r6711, r6712, r6713 and r6714 from 2.4 branch

Modified: trunk/MgDev/Common/Foundation/Data/NamedCollection.cpp
===================================================================
--- trunk/MgDev/Common/Foundation/Data/NamedCollection.cpp	2012-05-31 11:55:50 UTC (rev 6714)
+++ trunk/MgDev/Common/Foundation/Data/NamedCollection.cpp	2012-05-31 13:01:33 UTC (rev 6715)
@@ -111,7 +111,11 @@
 {
     MgNamedSerializable* item = FindItem(name);
     if (!item)
-        throw new MgObjectNotFoundException(L"GetItem", __LINE__, __WFILE__, NULL, L"", NULL); // EXC::Create(Exception::NLSGetMessage(NLSID(38_ITEMNOTFOUND),name));
+    {
+        MgStringCollection args;
+        args.Add(name);
+        throw new MgObjectNotFoundException(L"GetItem", __LINE__, __WFILE__, NULL, L"MgNoNameForObject", &args); // EXC::Create(Exception::NLSGetMessage(NLSID(38_ITEMNOTFOUND),name));
+    }
 
     return item;
 }

Modified: trunk/MgDev/Common/Foundation/System/Util.h
===================================================================
--- trunk/MgDev/Common/Foundation/System/Util.h	2012-05-31 11:55:50 UTC (rev 6714)
+++ trunk/MgDev/Common/Foundation/System/Util.h	2012-05-31 13:01:33 UTC (rev 6715)
@@ -20,6 +20,8 @@
 
 
 #include "LinuxMemoryStatus.h"
+#include <sstream>
+#include <iostream>
 
 // Math-related macros
 
@@ -583,15 +585,19 @@
 #define CHECKNULL(pointer, methodname)      \
 if (pointer == NULL)     \
 {                        \
+    MgStringCollection args; \
+    args.Add(L#pointer); \
     throw new MgNullReferenceException(methodname, \
-                                       __LINE__, __WFILE__, NULL, L"", NULL); \
+                                       __LINE__, __WFILE__, NULL, L"MgNullPointer", &args); \
 }
 
 #define CHECKARGUMENTNULL(pointer, methodname)      \
 if (pointer == NULL)     \
 {                        \
+    MgStringCollection args; \
+    args.Add(L#pointer); \
     throw new MgNullArgumentException(methodname, \
-                                       __LINE__, __WFILE__, NULL, L"", NULL); \
+                                       __LINE__, __WFILE__, NULL, L"MgNullArgument", &args); \
 }
 
 #define MG_CHECK_RANGE(value, min, max, methodName)                           \
@@ -599,8 +605,16 @@
     {                                                                         \
         if (NULL != methodName)                                               \
         {                                                                     \
+            std::wostringstream minStr;                                       \
+            minStr << min;                                                    \
+            std::wostringstream maxStr;                                       \
+            maxStr << max;                                                    \
+            MgStringCollection args;                                          \
+            args.Add(minStr.str());                                           \
+            args.Add(maxStr.str());                                           \
+            args.Add(L#value);                                                \
             throw new MgArgumentOutOfRangeException(                          \
-                methodName, __LINE__, __WFILE__, NULL, L"", NULL);            \
+                methodName, __LINE__, __WFILE__, NULL, L"MgArgumentOutOfRange", &args); \
         }                                                                     \
         else if (value < min)                                                 \
         {                                                                     \

Modified: trunk/MgDev/Common/MapGuideCommon/Resources/mapguide_en.res
===================================================================
--- trunk/MgDev/Common/MapGuideCommon/Resources/mapguide_en.res	2012-05-31 11:55:50 UTC (rev 6714)
+++ trunk/MgDev/Common/MapGuideCommon/Resources/mapguide_en.res	2012-05-31 13:01:33 UTC (rev 6715)
@@ -157,6 +157,7 @@
 # *****************************************************************************
 [ErrorDescription]
 MgArgumentsMismatch                                   = The arguments needed do not match the arguments provided.
+MgArgumentOutOfRange                                  = Argument out of range [%1, %2]: %3
 MgClassWOIdentity                                     = A class definition has no identity property.
 MgCollectionEmpty                                     = The collection cannot be empty.
 MgCoordinateSystemNotReadyException                   = The object is not ready for this operation.
@@ -228,6 +229,7 @@
 MgFailedToLoadFdoLibrary                              = Failed to load FDO library.
 MgFailedToRetrieveSystemExceptionMesage               = Failed to retrieve the system exception mesage. This message may not be unicode compliant.
 MgFailedToRetrieveThirdPartyExceptionMesage           = Failed to retrieve the third party exception mesage. This message may not be unicode compliant.
+MgFeatureSourceFormatInnerExceptionMessage            = Error occurred in Feature Source (%1): %2
 MgFeatureReaderIdNotFound                             = The feature reader ID was not found.
 MgFilenamesIdentical                                  = The filenames cannot be the same.
 MgFormatAllExceptionDetail                            = - %1(%2)
@@ -298,6 +300,9 @@
 MgMissingSrs                                          = No coordinate system specified.
 MgNameNotFound                                        = The name was not found.
 MgNoDataFromRenderer                                  = No data from renderer.
+MgNoNameForObject                                     = No object found for name (%1)
+MgNullArgument                                        = Null argument: %1
+MgNullPointer                                         = Null pointer: %1
 MgPropertyValuesEmpty                                 = The property values cannot be empty.
 MgReaderIdNotFound                                    = The reader ID was not found.
 MgRepositoryAlreadyOpened                             = The repository is already opened by another process (e.g. If you are running the server interactively as an application from the command line, are you also running the server as a service?).

Modified: trunk/MgDev/Common/PlatformBase/Services/FeatureReader.cpp
===================================================================
--- trunk/MgDev/Common/PlatformBase/Services/FeatureReader.cpp	2012-05-31 11:55:50 UTC (rev 6714)
+++ trunk/MgDev/Common/PlatformBase/Services/FeatureReader.cpp	2012-05-31 13:01:33 UTC (rev 6715)
@@ -75,7 +75,9 @@
     }
     else
     {
-        throw new MgObjectNotFoundException(L"MgFeatureReader.GetPropertyIndex", __LINE__, __WFILE__, NULL, L"", NULL);
+        MgStringCollection args;
+        args.Add(propertyName);
+        throw new MgObjectNotFoundException(L"MgFeatureReader.GetPropertyIndex", __LINE__, __WFILE__, NULL, L"MgNoNameForObject", &args);
         return -1; // to suppress compiler warning.
     }
 }

Modified: trunk/MgDev/Server/Server_VS2010.sln
===================================================================
--- trunk/MgDev/Server/Server_VS2010.sln	2012-05-31 11:55:50 UTC (rev 6714)
+++ trunk/MgDev/Server/Server_VS2010.sln	2012-05-31 13:01:33 UTC (rev 6715)
@@ -281,6 +281,7 @@
 		{DD0284A0-1ECE-4387-AED3-E9BF5EE74FF8}.Release|Win32.ActiveCfg = Release|Win32
 		{DD0284A0-1ECE-4387-AED3-E9BF5EE74FF8}.Release|Win32.Build.0 = Release|Win32
 		{DD0284A0-1ECE-4387-AED3-E9BF5EE74FF8}.Release|x64.ActiveCfg = Release|x64
+		{DD0284A0-1ECE-4387-AED3-E9BF5EE74FF8}.Release|x64.Build.0 = Release|x64
 		{F486B768-640A-445D-8C09-437C896EFFAD}.Debug|Win32.ActiveCfg = Debug|Win32
 		{F486B768-640A-445D-8C09-437C896EFFAD}.Debug|Win32.Build.0 = Debug|Win32
 		{F486B768-640A-445D-8C09-437C896EFFAD}.Debug|x64.ActiveCfg = Debug|x64

Modified: trunk/MgDev/Server/src/Common/Manager/FdoConnectionManager.cpp
===================================================================
--- trunk/MgDev/Server/src/Common/Manager/FdoConnectionManager.cpp	2012-05-31 11:55:50 UTC (rev 6714)
+++ trunk/MgDev/Server/src/Common/Manager/FdoConnectionManager.cpp	2012-05-31 13:01:33 UTC (rev 6715)
@@ -327,7 +327,7 @@
             __LINE__, __WFILE__, &arguments, L"", NULL);
     }
 
-    MG_FDOCONNECTION_MANAGER_CATCH(L"MgFdoConnectionManager.Open")
+    MG_FDOCONNECTION_MANAGER_CATCH_WITH_FEATURE_SOURCE(L"MgFdoConnectionManager.Open", resourceIdentifier)
     if (mgException != NULL)
     {
         // There was an exception so remove any connection
@@ -337,6 +337,31 @@
             // Update the # of current connections
             providerInfo->DecrementCurrentConnections();
         }
+
+        //HACK-ish: If an MgFdoException was thrown from below, keep the relevant details and 
+        //attach the feature source id. The end message will look a bit ugly, but the full contents
+        //of the inner exception is preserved. We have to do this because none of the methods called
+        //here that could throw MgFdoException accept a MgResourceIdentifier which we require to use
+        //any _WITH_FEATURE_SOURCE macro with
+        //
+        //MgException really needs better inner exception absorption mechanisms here
+        MgFdoException* ex = dynamic_cast<MgFdoException*>(mgException.p);
+        if (NULL != ex)
+        {
+            MgServerManager* serverManager = MgServerManager::GetInstance();
+            STRING locale = (NULL == serverManager) ?
+                MgResources::DefaultMessageLocale : serverManager->GetDefaultMessageLocale();
+
+            STRING message = ex->GetDetails(locale);
+            message += L"\n";
+            message += ex->GetStackTrace(locale);
+            MgStringCollection args;
+            args.Add(resourceIdentifier->ToString());
+            args.Add(message);
+
+            //Replace the exception to be thrown with our one
+            mgException = new MgFdoException(L"MgFdoConnectionManager.Open", __LINE__, __WFILE__, NULL, L"MgFeatureSourceFormatInnerExceptionMessage", &args);
+        }
     }
     MG_FDOCONNECTION_MANAGER_THROW()
 
@@ -644,7 +669,7 @@
                                               ltName,
                                               reuseOnly);
 
-    MG_FDOCONNECTION_MANAGER_CATCH_AND_THROW(L"MgFdoConnectionManager.FindFdoConnection")
+    MG_FDOCONNECTION_MANAGER_CATCH_AND_THROW_WITH_FEATURE_SOURCE(L"MgFdoConnectionManager.FindFdoConnection", resourceIdentifier)
 
     return pFdoConnection.Detach();
 }
@@ -2298,7 +2323,7 @@
         iterProviderInfoCollection++;
     }
 
-    MG_FDOCONNECTION_MANAGER_CATCH_AND_THROW(L"MgFdoConnectionManager.SetCachedFdoConnectionAsInvalid")
+    MG_FDOCONNECTION_MANAGER_CATCH_AND_THROW_WITH_FEATURE_SOURCE(L"MgFdoConnectionManager.SetCachedFdoConnectionAsInvalid", resource)
 
     return success;
 }

Modified: trunk/MgDev/Server/src/Common/Manager/FdoConnectionManager.h
===================================================================
--- trunk/MgDev/Server/src/Common/Manager/FdoConnectionManager.h	2012-05-31 11:55:50 UTC (rev 6714)
+++ trunk/MgDev/Server/src/Common/Manager/FdoConnectionManager.h	2012-05-31 13:01:33 UTC (rev 6715)
@@ -35,6 +35,9 @@
 #define MG_FDOCONNECTION_MANAGER_THROW()                       MG_FEATURE_SERVICE_THROW()
 #define MG_FDOCONNECTION_MANAGER_CATCH_AND_THROW(methodName)   MG_FEATURE_SERVICE_CATCH_AND_THROW(methodName)
 
+#define MG_FDOCONNECTION_MANAGER_CATCH_WITH_FEATURE_SOURCE(methodName, fsId)             MG_FEATURE_SERVICE_CATCH_WITH_FEATURE_SOURCE(methodName, fsId)
+#define MG_FDOCONNECTION_MANAGER_CATCH_AND_THROW_WITH_FEATURE_SOURCE(methodName, fsId)   MG_FEATURE_SERVICE_CATCH_AND_THROW_WITH_FEATURE_SOURCE(methodName, fsId)
+
 typedef struct {
     STRING ltName;                              // Current long transaction name for this connection
     FdoIConnection* pFdoConnection;

Modified: trunk/MgDev/Server/src/Services/Feature/ServerDescribeSchema.cpp
===================================================================
--- trunk/MgDev/Server/src/Services/Feature/ServerDescribeSchema.cpp	2012-05-31 11:55:50 UTC (rev 6714)
+++ trunk/MgDev/Server/src/Services/Feature/ServerDescribeSchema.cpp	2012-05-31 13:01:33 UTC (rev 6715)
@@ -635,7 +635,7 @@
         m_cacheManager->CheckPermission(resource, MgResourcePermission::ReadOnly);
     }
 
-    MG_FEATURE_SERVICE_CATCH_AND_THROW(L"MgServerDescribeSchema.DescribeSchemaAsXml")
+    MG_FEATURE_SERVICE_CATCH_AND_THROW_WITH_FEATURE_SOURCE(L"MgServerDescribeSchema.DescribeSchemaAsXml", resource)
 
     return schemaXml;
 }
@@ -1070,7 +1070,7 @@
         m_cacheManager->CheckPermission(resource, MgResourcePermission::ReadOnly);
     }
 
-    MG_FEATURE_SERVICE_CATCH_AND_THROW(L"MgServerDescribeSchema.GetClassDefinition")
+    MG_FEATURE_SERVICE_CATCH_AND_THROW_WITH_FEATURE_SOURCE(L"MgServerDescribeSchema.GetClassDefinition", resource)
 
     return classDefinition.Detach();
 }
@@ -1192,7 +1192,7 @@
     }
 
 
-    MG_FEATURE_SERVICE_CATCH_AND_THROW(L"MgServerDescribeSchema.GetIdentityProperties")
+    MG_FEATURE_SERVICE_CATCH_AND_THROW_WITH_FEATURE_SOURCE(L"MgServerDescribeSchema.GetIdentityProperties", resource)
 
     return classDefs.Detach();
 }

Modified: trunk/MgDev/Server/src/Services/Feature/ServerFeatureService.cpp
===================================================================
--- trunk/MgDev/Server/src/Services/Feature/ServerFeatureService.cpp	2012-05-31 11:55:50 UTC (rev 6714)
+++ trunk/MgDev/Server/src/Services/Feature/ServerFeatureService.cpp	2012-05-31 13:01:33 UTC (rev 6715)
@@ -240,7 +240,7 @@
     MgServerFeatureConnection msfc(resource);
     result = msfc.IsConnectionOpen();
 
-    MG_FEATURE_SERVICE_CATCH_AND_THROW(L"MgServerFeatureService.TestConnection")
+    MG_FEATURE_SERVICE_CATCH_AND_THROW_WITH_FEATURE_SOURCE(L"MgServerFeatureService.TestConnection", resource)
 
     return result;
 }
@@ -340,7 +340,7 @@
     MgServerDescribeSchema msds;
     schemas = msds.DescribeSchema(resource, schemaName, classNames);
 
-    MG_FEATURE_SERVICE_CATCH_AND_THROW(L"MgServerFeatureService.DescribeSchema");
+    MG_FEATURE_SERVICE_CATCH_AND_THROW_WITH_FEATURE_SOURCE(L"MgServerFeatureService.DescribeSchema", resource);
 
     return schemas.Detach();
 }
@@ -385,7 +385,7 @@
     MgServerDescribeSchema msds;
     schemaXml = msds.DescribeSchemaAsXml(resource, schemaName, classNames);
 
-    MG_FEATURE_SERVICE_CATCH_AND_THROW(L"MgServerFeatureService.DescribeSchemaAsXml");
+    MG_FEATURE_SERVICE_CATCH_AND_THROW_WITH_FEATURE_SOURCE(L"MgServerFeatureService.DescribeSchemaAsXml", resource);
 
     return schemaXml;
 }
@@ -459,7 +459,7 @@
     MgServerSelectFeatures mssf;
     reader = (MgFeatureReader*)mssf.SelectFeatures(resource, className, options, false);
 
-    MG_FEATURE_SERVICE_CATCH_AND_THROW(L"MgServerFeatureService.SelectFeatures")
+    MG_FEATURE_SERVICE_CATCH_AND_THROW_WITH_FEATURE_SOURCE(L"MgServerFeatureService.SelectFeatures", resource)
 
     return reader.Detach();
 }
@@ -567,7 +567,7 @@
     MgServerSelectFeatures mssf;
     reader = (MgDataReader*)mssf.SelectFeatures(resource, className, options, true);
 
-    MG_FEATURE_SERVICE_CATCH_AND_THROW(L"MgServerFeatureService.SelectAggregate");
+    MG_FEATURE_SERVICE_CATCH_AND_THROW_WITH_FEATURE_SOURCE(L"MgServerFeatureService.SelectAggregate", resource);
 
     return reader.Detach();
 }
@@ -707,7 +707,7 @@
 
     transaction = transactionPool->CreateTransaction(resource);
 
-    MG_FEATURE_SERVICE_CATCH_AND_THROW(L"MgServerFeatureService.BeginTransaction")
+    MG_FEATURE_SERVICE_CATCH_AND_THROW_WITH_FEATURE_SOURCE(L"MgServerFeatureService.BeginTransaction", resource)
 
     return transaction.Detach();
 }
@@ -973,7 +973,7 @@
     MgServerGetSpatialContexts msgsc;
     reader = msgsc.GetSpatialContexts(resource);
 
-    MG_FEATURE_SERVICE_CATCH_AND_THROW(L"MgServerFeatureService.GetSpatialContexts")
+    MG_FEATURE_SERVICE_CATCH_AND_THROW_WITH_FEATURE_SOURCE(L"MgServerFeatureService.GetSpatialContexts", resource)
 
     return reader.Detach();
 }
@@ -1067,7 +1067,7 @@
     // set the name in the manager
     MgLongTransactionManager::SetLongTransactionName(sessionId, featureSourceId, longTransactionName);
 
-    MG_FEATURE_SERVICE_CATCH_AND_THROW(L"MgServerFeatureService.SetLongTransaction")
+    MG_FEATURE_SERVICE_CATCH_AND_THROW_WITH_FEATURE_SOURCE(L"MgServerFeatureService.SetLongTransaction", featureSourceId)
 
     return true;
 }
@@ -1263,8 +1263,13 @@
 
             if (NULL == classFound.p)
             {
+                STRING qualifiedName = currSchemaName;
+                qualifiedName += L":";
+                qualifiedName += currClassName;
+                MgStringCollection args;
+                args.Add(qualifiedName);
                 throw new MgObjectNotFoundException(L"DescribeWfsFeatureType",
-                    __LINE__, __WFILE__, NULL, L"", NULL);
+                    __LINE__, __WFILE__, NULL, L"MgNoNameForObject", &args);
             }
             else
             {
@@ -1310,7 +1315,7 @@
 
     byteReader = bs->GetReader();
 
-    MG_FEATURE_SERVICE_CATCH_AND_THROW(L"MgServerFeatureService.DescribeWfsFeatureType")
+    MG_FEATURE_SERVICE_CATCH_AND_THROW_WITH_FEATURE_SOURCE(L"MgServerFeatureService.DescribeWfsFeatureType", featureSourceId)
 
     return byteReader.Detach();
 }

Modified: trunk/MgDev/Server/src/Services/Feature/ServerFeatureServiceExceptionDef.h
===================================================================
--- trunk/MgDev/Server/src/Services/Feature/ServerFeatureServiceExceptionDef.h	2012-05-31 11:55:50 UTC (rev 6714)
+++ trunk/MgDev/Server/src/Services/Feature/ServerFeatureServiceExceptionDef.h	2012-05-31 13:01:33 UTC (rev 6715)
@@ -46,6 +46,27 @@
                                                                               \
     MG_CATCH(methodName)                                                      \
 
+#define MG_FEATURE_SERVICE_CATCH_WITH_FEATURE_SOURCE(methodName, fsId)        \
+    }                                                                         \
+    catch (FdoException* e)                                                   \
+    {                                                                         \
+        STRING messageId;                                                     \
+        MgStringCollection arguments;                                         \
+        wchar_t* buf = (wchar_t*)e->GetExceptionMessage();                    \
+        INT64 nativeErrorCode = e->GetNativeErrorCode();                      \
+                                                                              \
+        if (NULL != buf)                                                      \
+        {                                                                     \
+            messageId = L"MgFeatureSourceFormatInnerExceptionMessage";        \
+            arguments.Add(fsId->ToString());                                  \
+            arguments.Add(buf);                                               \
+        }                                                                     \
+                                                                              \
+        FDO_SAFE_RELEASE(e);                                                  \
+        mgException = new MgFdoException(methodName, __LINE__, __WFILE__, NULL, messageId, &arguments, nativeErrorCode); \
+                                                                              \
+    MG_CATCH(methodName)                                                      \
+
 #define MG_FEATURE_SERVICE_THROW()                                            \
     MG_THROW()                                                                \
 
@@ -54,6 +75,11 @@
                                                                               \
     MG_FEATURE_SERVICE_THROW()                                                \
 
+#define MG_FEATURE_SERVICE_CATCH_AND_THROW_WITH_FEATURE_SOURCE(methodName, fsId) \
+    MG_FEATURE_SERVICE_CATCH_WITH_FEATURE_SOURCE(methodName, fsId)            \
+                                                                              \
+    MG_FEATURE_SERVICE_THROW()                                                \
+
 // The catch below is used when we want to mark a connection as no longer valid because
 // the underlying RDBMS has been stopped or the connection has been lost.
 
@@ -96,7 +122,8 @@
                 pFdoConnectionManager->SetCachedFdoConnectionAsInvalid(resource); \
             }                                                                 \
                                                                               \
-            messageId = L"MgFormatInnerExceptionMessage";                     \
+            messageId = L"MgFeatureSourceFormatInnerExceptionMessage";        \
+            arguments.Add(resource->ToString());                              \
             arguments.Add(buf);                                               \
         }                                                                     \
                                                                               \

Copied: trunk/MgDev/Server/src/UnitTesting/TestMisc.cpp (from rev 6713, branches/2.4/MgDev/Server/src/UnitTesting/TestMisc.cpp)
===================================================================
--- trunk/MgDev/Server/src/UnitTesting/TestMisc.cpp	                        (rev 0)
+++ trunk/MgDev/Server/src/UnitTesting/TestMisc.cpp	2012-05-31 13:01:33 UTC (rev 6715)
@@ -0,0 +1,261 @@
+//
+//  Copyright (C) 2004-2011 by Autodesk, Inc.
+//
+//  This library is free software; you can redistribute it and/or
+//  modify it under the terms of version 2.1 of the GNU Lesser
+//  General Public License as published by the Free Software Foundation.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+//
+
+#include "MapGuideCommon.h"
+#include "TestMisc.h"
+#include "../UnitTesting/CppUnitExtensions.h"
+#include "FoundationDefs.h"
+const STRING TEST_LOCALE = L"en";
+
+CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(TestMisc, "TestMisc");
+
+TestMisc::TestMisc()
+{
+}
+
+
+TestMisc::~TestMisc()
+{
+}
+
+
+void TestMisc::setUp()
+{
+}
+
+
+void TestMisc::tearDown()
+{
+}
+
+
+void TestMisc::TestStart()
+{
+    ACE_DEBUG((LM_INFO, ACE_TEXT("\nRunning Miscellaneous tests.\n")));
+}
+
+
+void TestMisc::TestEnd()
+{
+    ACE_DEBUG((LM_INFO, ACE_TEXT("\nMiscellaneous tests completed.\n\n")));
+}
+
+void TestMisc::TestCase_CommonExceptionMessages()
+{
+    try
+    {
+        MgObject* ptr = NULL;
+        CHECKNULL(ptr, L"TestMisc::TestCase_CommonExceptionMessages");
+    }
+    catch(MgException* ex)
+    {
+        STRING msg = ex->GetExceptionMessage(TEST_LOCALE);
+        //ACE_DEBUG((LM_INFO, ACE_TEXT("Exception: %W\n"), msg.c_str()));
+        std::string assertMsg = "Expected identifier 'ptr' in exception message: ";
+        assertMsg += MgUtil::WideCharToMultiByte(msg);
+        CPPUNIT_ASSERT_MESSAGE(assertMsg, msg.find(L"ptr") != STRING::npos);
+        ex->Release();
+    }
+
+    try
+    {
+        MgObject* ptr2 = NULL;
+        CHECKNULL((void*)ptr2, L"TestMisc::TestCase_CommonExceptionMessages");
+    }
+    catch(MgException* ex)
+    {
+        STRING msg = ex->GetExceptionMessage(TEST_LOCALE);
+        //ACE_DEBUG((LM_INFO, ACE_TEXT("Exception: %W\n"), msg.c_str()));
+        std::string assertMsg = "Expected identifier 'ptr2' in exception message: ";
+        assertMsg += MgUtil::WideCharToMultiByte(msg);
+        CPPUNIT_ASSERT_MESSAGE(assertMsg, msg.find(L"ptr2") != STRING::npos);
+        ex->Release();
+    }
+
+    try
+    {
+        MgObject* ptr3 = NULL;
+        CHECKARGUMENTNULL(ptr3, L"TestMisc::TestCase_CommonExceptionMessages");
+    }
+    catch(MgException* ex)
+    {
+        STRING msg = ex->GetExceptionMessage(TEST_LOCALE);
+        //ACE_DEBUG((LM_INFO, ACE_TEXT("Exception: %W\n"), msg.c_str()));
+        std::string assertMsg = "Expected identifier 'ptr3' in exception message: ";
+        assertMsg += MgUtil::WideCharToMultiByte(msg);
+        CPPUNIT_ASSERT_MESSAGE(assertMsg, msg.find(L"ptr3") != STRING::npos);
+        ex->Release();
+    }
+
+    try
+    {
+        MgObject* ptr4 = NULL;
+        CHECKARGUMENTNULL((void*)ptr4, L"TestMisc::TestCase_CommonExceptionMessages");
+    }
+    catch(MgException* ex)
+    {
+        STRING msg = ex->GetExceptionMessage(TEST_LOCALE);
+        //ACE_DEBUG((LM_INFO, ACE_TEXT("Exception: %W\n"), msg.c_str()));
+        std::string assertMsg = "Expected identifier 'ptr4' in exception message: ";
+        assertMsg += MgUtil::WideCharToMultiByte(msg);
+        CPPUNIT_ASSERT_MESSAGE(assertMsg, msg.find(L"ptr4") != STRING::npos);
+        ex->Release();
+    }
+
+    try
+    {
+        INT32 val = 1;
+        MG_CHECK_RANGE(val, 2, 3, L"TestMisc::TestCase_CommonExceptionMessages");
+    }
+    catch(MgException* ex)
+    {
+        STRING msg = ex->GetExceptionMessage(TEST_LOCALE);
+        //ACE_DEBUG((LM_INFO, ACE_TEXT("Exception: %W\n"), msg.c_str()));
+        std::string assertMsg = "Expected identifier 'val' in exception message: ";
+        assertMsg += MgUtil::WideCharToMultiByte(msg);
+        CPPUNIT_ASSERT_MESSAGE(assertMsg, msg.find(L"val") != STRING::npos);
+        ex->Release();
+    }
+
+    try
+    {
+        INT32 val = 1;
+        INT32 min = 2;
+        INT32 max = 3;
+        MG_CHECK_RANGE(val, min, max, L"TestMisc::TestCase_CommonExceptionMessages");
+    }
+    catch(MgException* ex)
+    {
+        STRING msg = ex->GetExceptionMessage(TEST_LOCALE);
+        //ACE_DEBUG((LM_INFO, ACE_TEXT("Exception: %W\n"), msg.c_str()));
+        std::string assertMsg = "Expected identifier '' in exception message: ";
+        assertMsg += MgUtil::WideCharToMultiByte(msg);
+        CPPUNIT_ASSERT_MESSAGE(assertMsg, msg.find(L"") != STRING::npos);
+        ex->Release();
+    }
+
+    try
+    {
+        INT64 val = 1L;
+        MG_CHECK_RANGE(val, 2L, 3L, L"TestMisc::TestCase_CommonExceptionMessages");
+    }
+    catch(MgException* ex)
+    {
+        STRING msg = ex->GetExceptionMessage(TEST_LOCALE);
+        //ACE_DEBUG((LM_INFO, ACE_TEXT("Exception: %W\n"), msg.c_str()));
+        std::string assertMsg = "Expected identifier '' in exception message: ";
+        assertMsg += MgUtil::WideCharToMultiByte(msg);
+        CPPUNIT_ASSERT_MESSAGE(assertMsg, msg.find(L"") != STRING::npos);
+        ex->Release();
+    }
+
+    try
+    {
+        INT64 val = 1L;
+        INT64 min = 2L;
+        INT64 max = 3L;
+        MG_CHECK_RANGE(val, min, max, L"TestMisc::TestCase_CommonExceptionMessages");
+    }
+    catch(MgException* ex)
+    {
+        STRING msg = ex->GetExceptionMessage(TEST_LOCALE);
+        //ACE_DEBUG((LM_INFO, ACE_TEXT("Exception: %W\n"), msg.c_str()));
+        std::string assertMsg = "Expected identifier '' in exception message: ";
+        assertMsg += MgUtil::WideCharToMultiByte(msg);
+        CPPUNIT_ASSERT_MESSAGE(assertMsg, msg.find(L"") != STRING::npos);
+        ex->Release();
+    }
+
+    try
+    {
+        float val = 1.0f;
+        MG_CHECK_RANGE(val, 2.0f, 3.0f, L"TestMisc::TestCase_CommonExceptionMessages");
+    }
+    catch(MgException* ex)
+    {
+        STRING msg = ex->GetExceptionMessage(TEST_LOCALE);
+        //ACE_DEBUG((LM_INFO, ACE_TEXT("Exception: %W\n"), msg.c_str()));
+        std::string assertMsg = "Expected identifier '' in exception message: ";
+        assertMsg += MgUtil::WideCharToMultiByte(msg);
+        CPPUNIT_ASSERT_MESSAGE(assertMsg, msg.find(L"") != STRING::npos);
+        ex->Release();
+    }
+
+    try
+    {
+        float val = 1.0f;
+        float min = 2.0f;
+        float max = 3.0f;
+        MG_CHECK_RANGE(val, min, max, L"TestMisc::TestCase_CommonExceptionMessages");
+    }
+    catch(MgException* ex)
+    {
+        STRING msg = ex->GetExceptionMessage(TEST_LOCALE);
+        //ACE_DEBUG((LM_INFO, ACE_TEXT("Exception: %W\n"), msg.c_str()));
+        std::string assertMsg = "Expected identifier '' in exception message: ";
+        assertMsg += MgUtil::WideCharToMultiByte(msg);
+        CPPUNIT_ASSERT_MESSAGE(assertMsg, msg.find(L"") != STRING::npos);
+        ex->Release();
+    }
+
+    try
+    {
+        double val = 1.0;
+        MG_CHECK_RANGE(val, 2.0, 3.0, L"TestMisc::TestCase_CommonExceptionMessages");
+    }
+    catch(MgException* ex)
+    {
+        STRING msg = ex->GetExceptionMessage(TEST_LOCALE);
+        //ACE_DEBUG((LM_INFO, ACE_TEXT("Exception: %W\n"), msg.c_str()));
+        std::string assertMsg = "Expected identifier '' in exception message: ";
+        assertMsg += MgUtil::WideCharToMultiByte(msg);
+        CPPUNIT_ASSERT_MESSAGE(assertMsg, msg.find(L"") != STRING::npos);
+        ex->Release();
+    }
+
+    try
+    {
+        double val = 1.0;
+        double min = 2.0;
+        double max = 3.0;
+        MG_CHECK_RANGE(val, min, max, L"TestMisc::TestCase_CommonExceptionMessages");
+    }
+    catch(MgException* ex)
+    {
+        STRING msg = ex->GetExceptionMessage(TEST_LOCALE);
+        //ACE_DEBUG((LM_INFO, ACE_TEXT("Exception: %W\n"), msg.c_str()));
+        std::string assertMsg = "Expected identifier '' in exception message: ";
+        assertMsg += MgUtil::WideCharToMultiByte(msg);
+        CPPUNIT_ASSERT_MESSAGE(assertMsg, msg.find(L"") != STRING::npos);
+        ex->Release();
+    }
+
+    try
+    {
+        Ptr<MgNamedCollection> coll = new MgNamedCollection(false);
+        coll->GetItem(L"Foo");
+    }
+    catch(MgException* ex)
+    {
+        STRING msg = ex->GetExceptionMessage(TEST_LOCALE);
+        //ACE_DEBUG((LM_INFO, ACE_TEXT("Exception: %W\n"), msg.c_str()));
+        std::string assertMsg = "Expected string 'Foo' in exception message: ";
+        assertMsg += MgUtil::WideCharToMultiByte(msg);
+        CPPUNIT_ASSERT_MESSAGE(assertMsg, msg.find(L"Foo") != STRING::npos);
+        ex->Release();
+    }
+}
\ No newline at end of file

Copied: trunk/MgDev/Server/src/UnitTesting/TestMisc.h (from rev 6713, branches/2.4/MgDev/Server/src/UnitTesting/TestMisc.h)
===================================================================
--- trunk/MgDev/Server/src/UnitTesting/TestMisc.h	                        (rev 0)
+++ trunk/MgDev/Server/src/UnitTesting/TestMisc.h	2012-05-31 13:01:33 UTC (rev 6715)
@@ -0,0 +1,45 @@
+//
+//  Copyright (C) 2004-2011 by Autodesk, Inc.
+//
+//  This library is free software; you can redistribute it and/or
+//  modify it under the terms of version 2.1 of the GNU Lesser
+//  General Public License as published by the Free Software Foundation.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+//
+
+#ifndef _TESTTILESERVICE_H
+#define _TESTTILESERVICE_H
+
+#include <cppunit/extensions/HelperMacros.h>
+
+class TestMisc : public CppUnit::TestFixture
+{
+    CPPUNIT_TEST_SUITE(TestMisc);
+    CPPUNIT_TEST(TestStart); // This must be the very first unit test
+
+    CPPUNIT_TEST(TestCase_CommonExceptionMessages);
+
+    CPPUNIT_TEST(TestEnd); // This must be the very last unit test
+    CPPUNIT_TEST_SUITE_END();
+
+public:
+    TestMisc();
+    ~TestMisc();
+
+    void setUp();
+    void tearDown();
+    void TestStart();
+    void TestEnd();
+
+    void TestCase_CommonExceptionMessages();
+};
+
+#endif

Modified: trunk/MgDev/Server/src/UnitTesting/UnitTesting.cpp
===================================================================
--- trunk/MgDev/Server/src/UnitTesting/UnitTesting.cpp	2012-05-31 11:55:50 UTC (rev 6714)
+++ trunk/MgDev/Server/src/UnitTesting/UnitTesting.cpp	2012-05-31 13:01:33 UTC (rev 6715)
@@ -53,6 +53,7 @@
             runner.addTest(CppUnit::TestFactoryRegistry::getRegistry("TestMdfModel").makeTest());
             runner.addTest(CppUnit::TestFactoryRegistry::getRegistry("TestKmlService").makeTest());
             runner.addTest(CppUnit::TestFactoryRegistry::getRegistry("TestMappingService").makeTest());
+            runner.addTest(CppUnit::TestFactoryRegistry::getRegistry("TestMisc").makeTest());
             runner.addTest(CppUnit::TestFactoryRegistry::getRegistry("TestRenderingService").makeTest());
             runner.addTest(CppUnit::TestFactoryRegistry::getRegistry("TestResourceService").makeTest());
             runner.addTest(CppUnit::TestFactoryRegistry::getRegistry("TestTileService").makeTest());
@@ -82,6 +83,7 @@
             ACE_OS::printf("  LogManager\n");
             ACE_OS::printf("  MappingService\n");
             ACE_OS::printf("  MdfModel\n");
+            ACE_OS::printf("  Misc\n");
             ACE_OS::printf("  Performance\n");
             ACE_OS::printf("  RenderingService\n");
             ACE_OS::printf("  ResourceService\n");
@@ -132,6 +134,11 @@
             ACE_DEBUG((LM_INFO, ACE_TEXT(">>>>> Running only MdfModel tests. <<<<<\n\n")));
             runner.addTest(CppUnit::TestFactoryRegistry::getRegistry("TestMdfModel").makeTest());
         }
+        else if(ACE_OS::strcasecmp(MG_WCHAR_TO_TCHAR(test), ACE_LIB_TEXT("Misc")) == 0)
+        {
+            ACE_DEBUG((LM_INFO, ACE_TEXT(">>>>> Running only Miscellaneous tests. <<<<<\n\n")));
+            runner.addTest(CppUnit::TestFactoryRegistry::getRegistry("TestMisc").makeTest());
+        }
         else if(ACE_OS::strcasecmp(MG_WCHAR_TO_TCHAR(test), ACE_LIB_TEXT("Performance")) == 0)
         {
             ACE_DEBUG((LM_INFO, ACE_TEXT(">>>>> Running only Performance tests. <<<<<\n\n")));
@@ -209,6 +216,7 @@
         runner.addTest(CppUnit::TestFactoryRegistry::getRegistry("TestMdfModel").makeTest());
         runner.addTest(CppUnit::TestFactoryRegistry::getRegistry("TestKmlService").makeTest());
         runner.addTest(CppUnit::TestFactoryRegistry::getRegistry("TestMappingService").makeTest());
+        runner.addTest(CppUnit::TestFactoryRegistry::getRegistry("TestMisc").makeTest());
         runner.addTest(CppUnit::TestFactoryRegistry::getRegistry("TestRenderingService").makeTest());
         runner.addTest(CppUnit::TestFactoryRegistry::getRegistry("TestResourceService").makeTest());
         runner.addTest(CppUnit::TestFactoryRegistry::getRegistry("TestTileService").makeTest());

Modified: trunk/MgDev/Server/src/UnitTesting/UnitTesting.vcproj
===================================================================
--- trunk/MgDev/Server/src/UnitTesting/UnitTesting.vcproj	2012-05-31 11:55:50 UTC (rev 6714)
+++ trunk/MgDev/Server/src/UnitTesting/UnitTesting.vcproj	2012-05-31 13:01:33 UTC (rev 6715)
@@ -410,6 +410,14 @@
 			>
 		</File>
 		<File
+			RelativePath=".\TestMisc.cpp"
+			>
+		</File>
+		<File
+			RelativePath=".\TestMisc.h"
+			>
+		</File>
+		<File
 			RelativePath=".\TestPerformance.cpp"
 			>
 		</File>

Modified: trunk/MgDev/Server/src/UnitTesting/UnitTesting.vcxproj
===================================================================
--- trunk/MgDev/Server/src/UnitTesting/UnitTesting.vcxproj	2012-05-31 11:55:50 UTC (rev 6714)
+++ trunk/MgDev/Server/src/UnitTesting/UnitTesting.vcxproj	2012-05-31 13:01:33 UTC (rev 6715)
@@ -201,6 +201,7 @@
     <ClInclude Include="TestLogManagerThread.h" />
     <ClInclude Include="TestMappingService.h" />
     <ClInclude Include="TestMdfModel.h" />
+    <ClInclude Include="TestMisc.h" />
     <ClInclude Include="TestPerformance.h" />
     <ClInclude Include="TestProfilingService.h" />
     <ClInclude Include="TestRenderingService.h" />
@@ -223,6 +224,7 @@
     <ClCompile Include="TestLogManagerThread.cpp" />
     <ClCompile Include="TestMappingService.cpp" />
     <ClCompile Include="TestMdfModel.cpp" />
+    <ClCompile Include="TestMisc.cpp" />
     <ClCompile Include="TestPerformance.cpp" />
     <ClCompile Include="TestProfilingService.cpp" />
     <ClCompile Include="TestRenderingService.cpp" />



More information about the mapguide-commits mailing list