[mapguide-commits] r9218 - in trunk/MgDev: . Common/Foundation/System Server/src/Core

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Wed Jun 21 08:53:47 PDT 2017


Author: jng
Date: 2017-06-21 08:53:47 -0700 (Wed, 21 Jun 2017)
New Revision: 9218

Added:
   trunk/MgDev/Server/src/Core/LoadPackageCommand.cpp
   trunk/MgDev/Server/src/Core/LoadPackageCommand.h
   trunk/MgDev/Server/src/Core/ServerInteractiveCommand.cpp
   trunk/MgDev/Server/src/Core/ServerInteractiveCommand.h
   trunk/MgDev/Server/src/Core/SetPwdCommand.cpp
   trunk/MgDev/Server/src/Core/SetPwdCommand.h
   trunk/MgDev/Server/src/Core/TestCommand.cpp
   trunk/MgDev/Server/src/Core/TestCommand.h
   trunk/MgDev/Server/src/Core/TestFdoCommand.cpp
   trunk/MgDev/Server/src/Core/TestFdoCommand.h
Modified:
   trunk/MgDev/
   trunk/MgDev/Common/Foundation/System/Resources.cpp
   trunk/MgDev/Common/Foundation/System/Resources.h
   trunk/MgDev/Server/src/Core/Makefile.am
   trunk/MgDev/Server/src/Core/Server.cpp
   trunk/MgDev/Server/src/Core/Server.h
   trunk/MgDev/Server/src/Core/ServerCore.vcxproj
   trunk/MgDev/Server/src/Core/ServerCore.vcxproj.filters
   trunk/MgDev/Server/src/Core/ServerCoreBuild.cpp
   trunk/MgDev/Server/src/Core/main.cpp
Log:
Merged revision(s) 9199-9217 from sandbox/jng/cmdline. This completes MapGuide RFC 16


Property changes on: trunk/MgDev
___________________________________________________________________
Modified: svn:mergeinfo
   - /branches/2.4/MgDev:6749-6756,6777-6783,6785-6787,6789,6791-6794,6796-6801,6954-6962,6986-7006
/branches/2.6/MgDev:8276-8286,8288-8292,8297,8299,8301,8303,8314-8315,8318,8335,8340,8354-8355,8365,8373
/branches/3.0/MgDev:8658,8705,8710
/branches/3.1/MgDev:9026,9058-9059,9067-9068
/sandbox/VC140:8684-8759
/sandbox/adsk/2.6l:8727
/sandbox/adsk/3.0m:8563,8584,8607,8625,8694-8695
/sandbox/adsk/3.1n:8871,8895,8901,8912-8913,8921-8922,8942,9019-9020
/sandbox/jng/clean_json:8818-9180
/sandbox/jng/convenience_apis:8262-8268,8271-8363
/sandbox/jng/createruntimemap:7486-7555
/sandbox/jng/dwftk:8321-8324,8328-8329,8331,8352
/sandbox/jng/geos34x:8256-8259
/sandbox/jng/php56x:8975-8985
/sandbox/jng/rfc155:8872-8884
/sandbox/jng/simplify:8814-9141
/sandbox/jng/tiling:8174-8208
/sandbox/jng/utfgrid:9179-9212
/sandbox/jng/v30:8212-8227
/sandbox/rfc94:5099-5163
   + /branches/2.4/MgDev:6749-6756,6777-6783,6785-6787,6789,6791-6794,6796-6801,6954-6962,6986-7006
/branches/2.6/MgDev:8276-8286,8288-8292,8297,8299,8301,8303,8314-8315,8318,8335,8340,8354-8355,8365,8373
/branches/3.0/MgDev:8658,8705,8710
/branches/3.1/MgDev:9026,9058-9059,9067-9068
/sandbox/VC140:8684-8759
/sandbox/adsk/2.6l:8727
/sandbox/adsk/3.0m:8563,8584,8607,8625,8694-8695
/sandbox/adsk/3.1n:8871,8895,8901,8912-8913,8921-8922,8942,9019-9020
/sandbox/jng/clean_json:8818-9180
/sandbox/jng/cmdline:9199-9217
/sandbox/jng/convenience_apis:8262-8268,8271-8363
/sandbox/jng/createruntimemap:7486-7555
/sandbox/jng/dwftk:8321-8324,8328-8329,8331,8352
/sandbox/jng/geos34x:8256-8259
/sandbox/jng/php56x:8975-8985
/sandbox/jng/rfc155:8872-8884
/sandbox/jng/simplify:8814-9141
/sandbox/jng/tiling:8174-8208
/sandbox/jng/utfgrid:9179-9212
/sandbox/jng/v30:8212-8227
/sandbox/rfc94:5099-5163

Modified: trunk/MgDev/Common/Foundation/System/Resources.cpp
===================================================================
--- trunk/MgDev/Common/Foundation/System/Resources.cpp	2017-06-15 16:13:06 UTC (rev 9217)
+++ trunk/MgDev/Common/Foundation/System/Resources.cpp	2017-06-21 15:53:47 UTC (rev 9218)
@@ -125,6 +125,16 @@
 const STRING MgResources::ServerCmdStopDescription      = L"  stop\n"\
                                                           L"      Stops the server service. Note: The service must be installed.\n\n";
 
+const STRING MgResources::ServerCmdLoadPackage          = L"loadpackage"; // Do not translate
+const STRING MgResources::ServerCmdLoadPackageInfo      = L"Loading the specified package.\n\n";
+const STRING MgResources::ServerCmdLoadPackageDescription = L"  loadpackage <package file path>\n"\
+                                                            L"      Loads the package at the given path.\n\n";
+
+const STRING MgResources::ServerCmdSetPwd               = L"setpwd"; // Do not translate
+const STRING MgResources::ServerCmdSetPwdInfo           = L"Setting the password for the specified user\n\n";
+const STRING MgResources::ServerCmdSetPwdDescription    = L"  setpwd <mapguide_username> <password>\n"\
+                                                          L"      Sets the password for the specified username.\n\n";
+
 const STRING MgResources::ServerCmdUnrecognizedInfo     = L"Unrecognized option: \"%s\".\n";
 
 const STRING MgResources::ServerCmdInstallFailed        = L"Failed to install the server service: \"%s\".\nError: %s";

Modified: trunk/MgDev/Common/Foundation/System/Resources.h
===================================================================
--- trunk/MgDev/Common/Foundation/System/Resources.h	2017-06-15 16:13:06 UTC (rev 9217)
+++ trunk/MgDev/Common/Foundation/System/Resources.h	2017-06-21 15:53:47 UTC (rev 9218)
@@ -216,6 +216,12 @@
     static const STRING ServerCmdTestDefaultTests;
     static const STRING ServerCmdTestListTests;
     static const STRING ServerCmdTestMode; // Backwards compatibility
+    static const STRING ServerCmdLoadPackage;
+    static const STRING ServerCmdLoadPackageInfo;
+    static const STRING ServerCmdLoadPackageDescription;
+    static const STRING ServerCmdSetPwd;
+    static const STRING ServerCmdSetPwdInfo;
+    static const STRING ServerCmdSetPwdDescription;
     static const STRING ServerCmdUninstall;
     static const STRING ServerCmdUninstallInfo;
     static const STRING ServerCmdUninstallDescription;

Copied: trunk/MgDev/Server/src/Core/LoadPackageCommand.cpp (from rev 9217, sandbox/jng/cmdline/Server/src/Core/LoadPackageCommand.cpp)
===================================================================
--- trunk/MgDev/Server/src/Core/LoadPackageCommand.cpp	                        (rev 0)
+++ trunk/MgDev/Server/src/Core/LoadPackageCommand.cpp	2017-06-21 15:53:47 UTC (rev 9218)
@@ -0,0 +1,70 @@
+#include "LoadPackageCommand.h"
+
+MgLoadPackageCommand::MgLoadPackageCommand(CREFSTRING locale, CREFSTRING path)
+    : MgServerInteractiveCommand()
+{
+    m_locale = locale;
+    m_path = path;
+}
+
+MgLoadPackageCommand::~MgLoadPackageCommand()
+{
+
+}
+
+INT32 MgLoadPackageCommand::Execute()
+{
+    INT32 nResult = 0;
+    try
+    {
+        if (MgFileUtil::IsFile(m_path))
+        {
+            // Let the site manager know that the check servers background thread needs to stop
+            MgSiteManager* siteManager = MgSiteManager::GetInstance();
+            siteManager->StopCheckServersThread();
+
+            // Set the user information for the current thread to be administrator.
+            //
+            // This is server-local, so no authentication is done. The MgServiceManager just needs to know the user when
+            // services are requested.
+            Ptr<MgUserInformation> adminUserInfo = new MgUserInformation(MgUser::Administrator, L"");
+            MgUserInformation::SetCurrentUserInfo(adminUserInfo);
+
+            MgServiceManager* serviceManager = MgServiceManager::GetInstance();
+            Ptr<MgResourceService> resSvc = dynamic_cast<MgResourceService*>(serviceManager->RequestService(MgServiceType::ResourceService));
+            if (NULL == (MgResourceService*)resSvc)
+            {
+                throw new MgServiceNotAvailableException(L"MgLoadPackageCommand.Execute", __LINE__, __WFILE__, NULL, L"", NULL);
+            }
+
+            Ptr<MgByteSource> bs = new MgByteSource(m_path);
+            Ptr<MgByteReader> br = bs->GetReader();
+
+            ACE_DEBUG((LM_INFO, ACE_TEXT("Loading package file: %W...\n\n"), m_path.c_str()));
+            resSvc->ApplyResourcePackage(br);
+            ACE_DEBUG((LM_INFO, ACE_TEXT("Package loaded.\n")));
+        }
+        else
+        {
+            ACE_DEBUG((LM_INFO, ACE_TEXT("Package file not found: %W\n\n"), m_path.c_str()));
+
+            nResult = -1;
+        }
+    }
+    catch (MgException* e)
+    {
+        ACE_DEBUG((LM_ERROR, ACE_TEXT("Unable to load the specified package.\n")));
+        ACE_DEBUG((LM_ERROR, ACE_TEXT("%W\n"), e->GetStackTrace(m_locale).c_str()));
+        SAFE_RELEASE(e);
+
+        nResult = -1;
+    }
+    catch (...)
+    {
+        ACE_DEBUG((LM_ERROR, ACE_TEXT("Unable to load the specified package.\n")));
+
+        nResult = -1;
+    }
+
+    return nResult;
+}

Copied: trunk/MgDev/Server/src/Core/LoadPackageCommand.h (from rev 9217, sandbox/jng/cmdline/Server/src/Core/LoadPackageCommand.h)
===================================================================
--- trunk/MgDev/Server/src/Core/LoadPackageCommand.h	                        (rev 0)
+++ trunk/MgDev/Server/src/Core/LoadPackageCommand.h	2017-06-21 15:53:47 UTC (rev 9218)
@@ -0,0 +1,36 @@
+//
+//  Copyright (C) 2004-2017 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 LOAD_PACKAGE_COMMAND_H
+#define LOAD_PACKAGE_COMMAND_H
+
+#include "MapGuideCommon.h"
+#include "ServerInteractiveCommand.h"
+
+class MgLoadPackageCommand : public MgServerInteractiveCommand
+{
+public:
+    MgLoadPackageCommand(CREFSTRING locale, CREFSTRING path);
+    virtual ~MgLoadPackageCommand();
+    virtual INT32 Execute();
+
+private:
+    STRING m_locale;
+    STRING m_path;
+};
+
+#endif

Modified: trunk/MgDev/Server/src/Core/Makefile.am
===================================================================
--- trunk/MgDev/Server/src/Core/Makefile.am	2017-06-15 16:13:06 UTC (rev 9217)
+++ trunk/MgDev/Server/src/Core/Makefile.am	2017-06-21 15:53:47 UTC (rev 9218)
@@ -56,6 +56,7 @@
   EventTimerManager.cpp \
   FeatureServiceCacheTimeLimitEventHandler.cpp \
   main.cpp \
+  LoadPackageCommand.cpp \
   OperationThread.cpp \
   PerformanceLoggingEventHandler.cpp \
   RepositoryCheckpointEventHandler.cpp \
@@ -63,10 +64,14 @@
   ResourceServiceCacheTimeLimitEventHandler.cpp \
   Server.cpp \
   ServerFactory.cpp \
+  ServerInteractiveCommand.cpp \
   ServiceHandlerFactory.cpp \
   ServiceRegistrationEventHandler.cpp \
   SessionTimeoutEventHandler.cpp \
+  SetPwdCommand.cpp \
   SignalHandler.cpp \
+  TestCommand.cpp \
+  TestFdoCommand.cpp \
   TimedEvent.cpp \
   TimedEventHandler.cpp
 
@@ -78,6 +83,7 @@
   EventTimer.h \
   EventTimerManager.h \
   FeatureServiceCacheTimeLimitEventHandler.h \
+  LoadPackageCommand.h \
   OperationThread.h \
   PerformanceLoggingEventHandler.h \
   RepositoryCheckpointEventHandler.h \
@@ -85,9 +91,13 @@
   ResourceServiceCacheTimeLimitEventHandler.h \
   Server.h \
   ServiceHandlerFactory.h \
+  ServerInteractiveCommand.h \
   ServiceRegistrationEventHandler.h \
   SessionTimeoutEventHandler.h \
+  SetPwdCommand.h \
   SignalHandler.h \
+  TestCommand.h \
+  TestFdoCommand.h \
   TimedEvent.h \
   TimedEventHandler.h
 

Modified: trunk/MgDev/Server/src/Core/Server.cpp
===================================================================
--- trunk/MgDev/Server/src/Core/Server.cpp	2017-06-15 16:13:06 UTC (rev 9217)
+++ trunk/MgDev/Server/src/Core/Server.cpp	2017-06-21 15:53:47 UTC (rev 9218)
@@ -31,11 +31,18 @@
 #include "ServerFeatureTransactionPool.h"
 #include "ServerResourceService.h"
 
+#include "ServerSiteService.h"
+
 #include "Stylizer.h"
 #include "Bounds.h"
 #include "Renderer.h"
 #include "MappingUtil.h"
 
+#include "LoadPackageCommand.h"
+#include "SetPwdCommand.h"
+#include "TestCommand.h"
+#include "TestFdoCommand.h"
+
 #ifdef _DEBUG
 void DebugOutput(const ACE_TCHAR* format, ...)
 {
@@ -75,11 +82,12 @@
     ACE_DEBUG ((LM_DEBUG, ACE_TEXT("ACE_WIN64 NOT DEFINED\n")));
 #endif
 
-    reactor(ACE_Reactor::instance());
-
-    m_bTestMode = false;
     m_bTestFdo = false;
+    m_bTestMode = false;
 
+    reactor(ACE_Reactor::instance());
+    m_command.reset(NULL);
+
 #ifdef _DEBUG
     m_nClientRequestLimit = -1;   // -1 = No limit. DEBUG ONLY
 #endif
@@ -221,39 +229,76 @@
         if((ACE_OS::strcasecmp(parameter, MG_WCHAR_TO_TCHAR(MgResources::ServerCmdTest)) == 0) ||
            (ACE_OS::strcasecmp(parameter, MG_WCHAR_TO_TCHAR(MgResources::ServerCmdTestMode)) == 0))
         {
+            MgServerManager* pServerManager = MgServerManager::GetInstance();
+
             // Test mode
             m_bTestMode = true;
-            m_strTestFileName = L"";    // Default to no output filename
-            m_strTestName = MgResources::ServerCmdTestDefaultTests;     // Default to all of the tests
+            STRING outputFile = L"";    // Default to no output filename
+            STRING subSuite = MgResources::ServerCmdTestDefaultTests;     // Default to all of the tests
 
             // If there is a 2nd parameter it is the test to run
             if(argc > 2)
             {
-                m_strTestName = MG_TCHAR_TO_WCHAR(argv[2]);
+                subSuite = MG_TCHAR_TO_WCHAR(argv[2]);
             }
 
             // If there is a 3rd parameter it is the output filename
             if(argc > 3)
             {
-                m_strTestFileName = MG_TCHAR_TO_WCHAR(argv[3]);
+                outputFile = MG_TCHAR_TO_WCHAR(argv[3]);
             }
+
+            m_command.reset(new MgTestCommand(pServerManager->GetDefaultMessageLocale(), subSuite, outputFile));
         }
         else if(ACE_OS::strcasecmp(parameter, MG_WCHAR_TO_TCHAR(MgResources::ServerCmdTestFdo)) == 0)
         {
+            MgServerManager* pServerManager = MgServerManager::GetInstance();
+
             // Test FDO
             m_bTestFdo = true;
+            STRING outputFile = L"";
 
             // If there is a 2nd parameter it is the output filename
             if(argc > 2)
             {
-                m_strTestFileName = MG_TCHAR_TO_WCHAR(argv[2]);
+                outputFile = MG_TCHAR_TO_WCHAR(argv[2]);
             }
-            else
+
+            m_command.reset(new MgTestFdoCommand(pServerManager->GetDefaultMessageLocale(), outputFile));
+        }
+        else if (ACE_OS::strcasecmp(parameter, MG_WCHAR_TO_TCHAR(MgResources::ServerCmdLoadPackage)) == 0)
+        {
+            MgServerManager* pServerManager = MgServerManager::GetInstance();
+
+            // Package loading mode
+            STRING packagePath = L"";
+
+            // If there is a 2nd parameter it is the package filename
+            if (argc > 2)
             {
-                m_strTestFileName = L"";
+                packagePath = MG_TCHAR_TO_WCHAR(argv[2]);
             }
+
+            m_command.reset(new MgLoadPackageCommand(pServerManager->GetDefaultMessageLocale(), packagePath));
         }
+        else if (ACE_OS::strcasecmp(parameter, MG_WCHAR_TO_TCHAR(MgResources::ServerCmdSetPwd)) == 0)
+        {
+            MgServerManager* pServerManager = MgServerManager::GetInstance();
 
+            // Password changing mode
+            STRING strUser = L"";
+            STRING strPassword = L"";
+            if (argc > 2)
+            {
+                strUser = MG_TCHAR_TO_WCHAR(argv[2]);
+            }
+            if (argc > 3)
+            {
+                strPassword = MG_TCHAR_TO_WCHAR(argv[3]);
+            }
+
+            m_command.reset(new MgSetPwdCommand(pServerManager->GetDefaultMessageLocale(), strUser, strPassword));
+        }
         delete[] parameter;
     }
 }
@@ -271,220 +316,10 @@
 
     MgServerManager* pServerManager = MgServerManager::GetInstance();
 
-    if(m_bTestMode)
+    if (m_command.get()) //An interactive command was set, run it
     {
-        // Run the test cases
-
-        typedef int (*EXECUTE)(CREFSTRING, CREFSTRING);
-
-        MG_LOG_TRACE_ENTRY(L"MgServer::svc() - Running the server unit tests.");
-        ACE_DEBUG((LM_INFO, ACE_TEXT("Preparing to run the unit tests...\n\n")));
-
-        try
-        {
-            // Let the site manager know that the check servers background thread needs to stop
-            MgSiteManager* siteManager = MgSiteManager::GetInstance();
-            siteManager->StopCheckServersThread();
-
-            // Change the log file names to use the unit test names because we don't want to replace the existing log files
-            MgLogManager* pLogManager = MgLogManager::GetInstance();
-            STRING filename;
-
-            filename = L"Test" + MgLogManager::DefaultAccessLogFileName;
-            pLogManager->SetAccessLogFileName(filename);
-
-            filename = L"Test" + MgLogManager::DefaultAdminLogFileName;
-            pLogManager->SetAdminLogFileName(filename);
-
-            filename = L"Test" + MgLogManager::DefaultAuthenticationLogFileName;
-            pLogManager->SetAuthenticationLogFileName(filename);
-
-            filename = L"Test" + MgLogManager::DefaultErrorLogFileName;
-            pLogManager->SetErrorLogFileName(filename);
-
-            filename = L"Test" + MgLogManager::DefaultSessionLogFileName;
-            pLogManager->SetSessionLogFileName(filename);
-
-            filename = L"Test" + MgLogManager::DefaultTraceLogFileName;
-            pLogManager->SetTraceLogFileName(filename);
-
-            EXECUTE execute = NULL;
-
-        #ifdef _WIN32
-            HMODULE hlib = NULL;
-            #ifdef _DEBUG // load debug dll
-            STRING library = L"MgUnitTestingd.dll";
-            hlib = LoadLibrary(library.c_str());
-            #else // Load Release dll
-            STRING library = L"MgUnitTesting.dll";
-            hlib = LoadLibrary(library.c_str());
-            #endif
-
-            if (hlib != NULL)
-            {
-                execute = (EXECUTE)GetProcAddress(hlib, "Execute");
-            }
-            else
-            {
-                ACE_DEBUG((LM_INFO, ACE_TEXT("Cannot open library: %W\n"), library.c_str()));
-                throw new MgUnclassifiedException(L"MgServer.svc", __LINE__, __WFILE__, NULL, L"", NULL);
-            }
-        #else
-            string library = "libMgUnitTesting.so";
-            void* hlib = dlopen(library.c_str(), RTLD_NOW);
-
-            if (hlib != NULL)
-            {
-                execute = (EXECUTE)dlsym(hlib, "Execute");
-            }
-            else
-            {
-                ACE_DEBUG((LM_INFO, ACE_TEXT("Cannot open library: %s\n"), library.c_str()));
-                throw new MgUnclassifiedException(L"MgServer.svc", __LINE__, __WFILE__, NULL, L"", NULL);
-            }
-        #endif // _WIN32
-            if (execute != NULL)
-            {
-                nResult = (*execute)(m_strTestFileName, m_strTestName);
-
-                // The build script does not work with negative return codes, which is what is returned on a failure from CPPUnit.
-                // Therefore, we change the -1 result to a positive 1 to indicate to the build script that an error occurred.
-                if(nResult < 0)
-                {
-                    nResult = -(nResult);
-                }
-            }
-            else
-            {
-                // Failed to retrieve function
-                ACE_DEBUG((LM_INFO, ACE_TEXT("Cannot locate 'Execute' procedure address inside library.\n")));
-                throw new MgUnclassifiedException(L"MgServer.svc", __LINE__, __WFILE__, NULL, L"", NULL);
-            }
-
-            ACE_DEBUG((LM_INFO, ACE_TEXT("Finished running the unit tests.\n\n")));
-        }
-        catch (MgException* e)
-        {
-            ACE_DEBUG((LM_ERROR, ACE_TEXT("Unable to run all the unit tests.\n")));
-            ACE_DEBUG((LM_ERROR, ACE_TEXT("%W\n"), e->GetStackTrace(pServerManager->GetDefaultMessageLocale()).c_str()));
-            SAFE_RELEASE(e);
-
-            nResult = -1;
-        }
-        catch (...)
-        {
-            ACE_DEBUG((LM_ERROR, ACE_TEXT("Unable to run all the unit tests.\n")));
-
-            nResult = -1;
-        }
+        nResult = m_command->Execute();
     }
-    else if(m_bTestFdo)
-    {
-        // Run the FDO test cases
-
-        typedef int (*EXECUTE)(CREFSTRING);
-
-        MG_LOG_TRACE_ENTRY(L"MgServer::svc() - Running the FDO unit tests.");
-        ACE_DEBUG((LM_INFO, ACE_TEXT("Preparing to run the FDO unit tests...\n\n")));
-
-        try
-        {
-            // Let the site manager know that the check servers background thread needs to stop
-            MgSiteManager* siteManager = MgSiteManager::GetInstance();
-            siteManager->StopCheckServersThread();
-
-            // Change the log file names to use the unit test names because we don't want to replace the existing log files
-            MgLogManager* pLogManager = MgLogManager::GetInstance();
-            STRING filename;
-
-            filename = L"Test" + MgLogManager::DefaultAccessLogFileName;
-            pLogManager->SetAccessLogFileName(filename);
-
-            filename = L"Test" + MgLogManager::DefaultAdminLogFileName;
-            pLogManager->SetAdminLogFileName(filename);
-
-            filename = L"Test" + MgLogManager::DefaultAuthenticationLogFileName;
-            pLogManager->SetAuthenticationLogFileName(filename);
-
-            filename = L"Test" + MgLogManager::DefaultErrorLogFileName;
-            pLogManager->SetErrorLogFileName(filename);
-
-            filename = L"Test" + MgLogManager::DefaultSessionLogFileName;
-            pLogManager->SetSessionLogFileName(filename);
-
-            filename = L"Test" + MgLogManager::DefaultTraceLogFileName;
-            pLogManager->SetTraceLogFileName(filename);
-
-            EXECUTE execute = NULL;
-
-        #ifdef _WIN32
-            HMODULE hlib = NULL;
-            #ifdef _DEBUG // load debug dll
-            STRING library = L"MgFdoUnitTestingd.dll";
-            hlib = LoadLibrary(library.c_str());
-            #else // Load Release dll
-            STRING library = L"MgFdoUnitTesting.dll";
-            hlib = LoadLibrary(library.c_str());
-            #endif
-
-            if (hlib != NULL)
-            {
-                execute = (EXECUTE)GetProcAddress(hlib, "Execute");
-            }
-            else
-            {
-                ACE_DEBUG((LM_INFO, ACE_TEXT("Cannot open library: %W\n"), library.c_str()));
-                throw new MgUnclassifiedException(L"MgServer.svc", __LINE__, __WFILE__, NULL, L"", NULL);
-            }
-        #else
-            string library = "libMgFdoUnitTesting.so";
-            void* hlib = dlopen(library.c_str(), RTLD_NOW);
-
-            if (hlib != NULL)
-            {
-                execute = (EXECUTE)dlsym(hlib, "Execute");
-            }
-            else
-            {
-                ACE_DEBUG((LM_INFO, ACE_TEXT("Cannot open library: %s\n"), library.c_str()));
-                throw new MgUnclassifiedException(L"MgServer.svc", __LINE__, __WFILE__, NULL, L"", NULL);
-            }
-        #endif // _WIN32
-            if (execute != NULL)
-            {
-                nResult = (*execute)(m_strTestFileName);
-
-                // The build script does not work with negative return codes, which is what is returned on a failure from CPPUnit.
-                // Therefore, we change the -1 result to a positive 1 to indicate to the build script that an error occurred.
-                if(nResult < 0)
-                {
-                    nResult = -(nResult);
-                }
-            }
-            else
-            {
-                // Failed to retrieve function
-                ACE_DEBUG((LM_INFO, ACE_TEXT("Cannot locate 'Execute' procedure address inside library.\n")));
-                throw new MgUnclassifiedException(L"MgServer.svc", __LINE__, __WFILE__, NULL, L"", NULL);
-            }
-
-            ACE_DEBUG((LM_INFO, ACE_TEXT("Finished running the FDO unit tests.\n")));
-        }
-        catch (MgException* e)
-        {
-            ACE_DEBUG((LM_ERROR, ACE_TEXT("Unable to run all the FDO unit tests.\n")));
-            ACE_DEBUG((LM_ERROR, ACE_TEXT("%W\n"), e->GetStackTrace(pServerManager->GetDefaultMessageLocale()).c_str()));
-            SAFE_RELEASE(e);
-
-            nResult = -1;
-        }
-        catch (...)
-        {
-            ACE_DEBUG((LM_ERROR, ACE_TEXT("Unable to run all the FDO unit tests.\n")));
-
-            nResult = -1;
-        }
-    }
     else
     {
         try

Modified: trunk/MgDev/Server/src/Core/Server.h
===================================================================
--- trunk/MgDev/Server/src/Core/Server.h	2017-06-15 16:13:06 UTC (rev 9217)
+++ trunk/MgDev/Server/src/Core/Server.h	2017-06-21 15:53:47 UTC (rev 9218)
@@ -20,6 +20,7 @@
 
 #include "MapGuideCommon.h"
 #include "EventTimerManager.h"
+#include "ServerInteractiveCommand.h"
 
 #ifdef _WIN32
 #include "ace/NT_Service.h"
@@ -121,10 +122,9 @@
     ///////////////////////////////////////////////////////
     /// Member data
 private:
+    std::auto_ptr<MgServerInteractiveCommand> m_command;
     bool m_bTestMode;
     bool m_bTestFdo;
-    STRING m_strTestFileName;
-    STRING m_strTestName;
 
 #ifdef _DEBUG
     INT32 m_nClientRequestLimit;        // DEBUG ONLY

Modified: trunk/MgDev/Server/src/Core/ServerCore.vcxproj
===================================================================
--- trunk/MgDev/Server/src/Core/ServerCore.vcxproj	2017-06-15 16:13:06 UTC (rev 9217)
+++ trunk/MgDev/Server/src/Core/ServerCore.vcxproj	2017-06-21 15:53:47 UTC (rev 9218)
@@ -249,6 +249,12 @@
       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
     </ClCompile>
+    <ClCompile Include="LoadPackageCommand.cpp">
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
+    </ClCompile>
     <ClCompile Include="PerformanceLoggingEventHandler.cpp">
       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
@@ -273,6 +279,12 @@
       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
     </ClCompile>
+    <ClCompile Include="ServerInteractiveCommand.cpp">
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
+    </ClCompile>
     <ClCompile Include="ServiceRegistrationEventHandler.cpp">
       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
@@ -285,6 +297,24 @@
       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
     </ClCompile>
+    <ClCompile Include="SetPwdCommand.cpp">
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
+    </ClCompile>
+    <ClCompile Include="TestFdoCommand.cpp">
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
+    </ClCompile>
+    <ClCompile Include="TestCommand.cpp">
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
+    </ClCompile>
     <ClCompile Include="TimedEvent.cpp">
       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
@@ -348,12 +378,17 @@
     <ClInclude Include="EventTimer.h" />
     <ClInclude Include="EventTimerManager.h" />
     <ClInclude Include="FeatureServiceCacheTimeLimitEventHandler.h" />
+    <ClInclude Include="LoadPackageCommand.h" />
     <ClInclude Include="PerformanceLoggingEventHandler.h" />
     <ClInclude Include="RepositoryCheckpointEventHandler.h" />
     <ClInclude Include="ResourceChangeEventHandler.h" />
     <ClInclude Include="ResourceServiceCacheTimeLimitEventHandler.h" />
+    <ClInclude Include="ServerInteractiveCommand.h" />
     <ClInclude Include="ServiceRegistrationEventHandler.h" />
     <ClInclude Include="SessionTimeoutEventHandler.h" />
+    <ClInclude Include="SetPwdCommand.h" />
+    <ClInclude Include="TestCommand.h" />
+    <ClInclude Include="TestFdoCommand.h" />
     <ClInclude Include="TimedEvent.h" />
     <ClInclude Include="TimedEventHandler.h" />
     <ClInclude Include="ClientAcceptor.h" />

Modified: trunk/MgDev/Server/src/Core/ServerCore.vcxproj.filters
===================================================================
--- trunk/MgDev/Server/src/Core/ServerCore.vcxproj.filters	2017-06-15 16:13:06 UTC (rev 9217)
+++ trunk/MgDev/Server/src/Core/ServerCore.vcxproj.filters	2017-06-21 15:53:47 UTC (rev 9218)
@@ -4,6 +4,9 @@
     <Filter Include="TimedEventHandlers">
       <UniqueIdentifier>{73580568-ac7b-4016-8439-2059bd65dc97}</UniqueIdentifier>
     </Filter>
+    <Filter Include="Commands">
+      <UniqueIdentifier>{049d02ba-050a-40b1-a175-00a994d8cd91}</UniqueIdentifier>
+    </Filter>
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include="ConnectionTimeoutEventHandler.cpp">
@@ -56,6 +59,19 @@
     <ClCompile Include="ResourceServiceCacheTimeLimitEventHandler.cpp">
       <Filter>TimedEventHandlers</Filter>
     </ClCompile>
+    <ClCompile Include="ServerInteractiveCommand.cpp" />
+    <ClCompile Include="LoadPackageCommand.cpp">
+      <Filter>Commands</Filter>
+    </ClCompile>
+    <ClCompile Include="SetPwdCommand.cpp">
+      <Filter>Commands</Filter>
+    </ClCompile>
+    <ClCompile Include="TestCommand.cpp">
+      <Filter>Commands</Filter>
+    </ClCompile>
+    <ClCompile Include="TestFdoCommand.cpp">
+      <Filter>Commands</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="ConnectionTimeoutEventHandler.h">
@@ -105,6 +121,19 @@
     <ClInclude Include="ResourceServiceCacheTimeLimitEventHandler.h">
       <Filter>TimedEventHandlers</Filter>
     </ClInclude>
+    <ClInclude Include="ServerInteractiveCommand.h" />
+    <ClInclude Include="LoadPackageCommand.h">
+      <Filter>Commands</Filter>
+    </ClInclude>
+    <ClInclude Include="SetPwdCommand.h">
+      <Filter>Commands</Filter>
+    </ClInclude>
+    <ClInclude Include="TestCommand.h">
+      <Filter>Commands</Filter>
+    </ClInclude>
+    <ClInclude Include="TestFdoCommand.h">
+      <Filter>Commands</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <ResourceCompile Include="ServerCore.rc" />

Modified: trunk/MgDev/Server/src/Core/ServerCoreBuild.cpp
===================================================================
--- trunk/MgDev/Server/src/Core/ServerCoreBuild.cpp	2017-06-15 16:13:06 UTC (rev 9217)
+++ trunk/MgDev/Server/src/Core/ServerCoreBuild.cpp	2017-06-21 15:53:47 UTC (rev 9218)
@@ -36,3 +36,10 @@
 #include "TimedEvent.cpp"
 #include "TimedEventHandler.cpp"
 #include "ServerFactory.cpp"
+
+// Commands
+#include "ServerInteractiveCommand.cpp"
+#include "TestCommand.cpp"
+#include "TestFdoCommand.cpp"
+#include "LoadPackageCommand.cpp"
+#include "SetPwdCommand.cpp"
\ No newline at end of file

Copied: trunk/MgDev/Server/src/Core/ServerInteractiveCommand.cpp (from rev 9217, sandbox/jng/cmdline/Server/src/Core/ServerInteractiveCommand.cpp)
===================================================================
--- trunk/MgDev/Server/src/Core/ServerInteractiveCommand.cpp	                        (rev 0)
+++ trunk/MgDev/Server/src/Core/ServerInteractiveCommand.cpp	2017-06-21 15:53:47 UTC (rev 9218)
@@ -0,0 +1,12 @@
+#include "ServerInteractiveCommand.h"
+
+
+
+MgServerInteractiveCommand::MgServerInteractiveCommand()
+{
+}
+
+
+MgServerInteractiveCommand::~MgServerInteractiveCommand()
+{
+}

Copied: trunk/MgDev/Server/src/Core/ServerInteractiveCommand.h (from rev 9217, sandbox/jng/cmdline/Server/src/Core/ServerInteractiveCommand.h)
===================================================================
--- trunk/MgDev/Server/src/Core/ServerInteractiveCommand.h	                        (rev 0)
+++ trunk/MgDev/Server/src/Core/ServerInteractiveCommand.h	2017-06-21 15:53:47 UTC (rev 9218)
@@ -0,0 +1,33 @@
+//
+//  Copyright (C) 2004-2017 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 SERVER_INTERACTIVE_COMMAND_H
+#define SERVER_INTERACTIVE_COMMAND_H
+
+// The base class of all interactive commands
+class MgServerInteractiveCommand
+{
+protected:
+    MgServerInteractiveCommand();
+
+public:
+    virtual ~MgServerInteractiveCommand();
+
+    virtual INT32 Execute() = 0;
+};
+
+#endif
\ No newline at end of file

Copied: trunk/MgDev/Server/src/Core/SetPwdCommand.cpp (from rev 9217, sandbox/jng/cmdline/Server/src/Core/SetPwdCommand.cpp)
===================================================================
--- trunk/MgDev/Server/src/Core/SetPwdCommand.cpp	                        (rev 0)
+++ trunk/MgDev/Server/src/Core/SetPwdCommand.cpp	2017-06-21 15:53:47 UTC (rev 9218)
@@ -0,0 +1,81 @@
+#include "SetPwdCommand.h"
+
+MgSetPwdCommand::MgSetPwdCommand(CREFSTRING locale, CREFSTRING userName, CREFSTRING password)
+    : MgServerInteractiveCommand()
+{
+    m_locale = locale;
+    m_strUser = userName;
+    m_strPassword = password;
+}
+
+
+MgSetPwdCommand::~MgSetPwdCommand()
+{
+}
+
+INT32 MgSetPwdCommand::Execute()
+{
+    INT32 nResult = 0;
+    try
+    {
+        // Let the site manager know that the check servers background thread needs to stop
+        MgSiteManager* siteManager = MgSiteManager::GetInstance();
+        siteManager->StopCheckServersThread();
+
+        // Set the user information for the current thread to be administrator.
+        //
+        // This is server-local, so no authentication is done. The MgServiceManager just needs to know the user when
+        // services are requested.
+        Ptr<MgUserInformation> adminUserInfo = new MgUserInformation(MgUser::Administrator, L"");
+        MgUserInformation::SetCurrentUserInfo(adminUserInfo);
+
+        MgServiceManager* serviceManager = MgServiceManager::GetInstance();
+        Ptr<MgServerSiteService> pService = dynamic_cast<MgServerSiteService*>(serviceManager->RequestService(MgServiceType::SiteService));
+        if (NULL == (MgServerSiteService*)pService)
+        {
+            throw new MgServiceNotAvailableException(L"MgSetPwdCommand.Execute", __LINE__, __WFILE__, NULL, L"", NULL);
+        }
+
+        if (m_strUser.empty()) //Need to have passed username
+        {
+            ACE_DEBUG((LM_INFO, ACE_TEXT("No username specified.\n")));
+            nResult = -1;
+        }
+        else if (m_strPassword.empty()) //Need to have passed pwd
+        {
+            ACE_DEBUG((LM_INFO, ACE_TEXT("No password specified.\n")));
+            nResult = -1;
+        }
+        else
+        {
+            //Anonymous has no password, so there's nothing to set
+            if (m_strUser == MgUser::Anonymous)
+            {
+                ACE_DEBUG((LM_INFO, ACE_TEXT("Cannot change password for Anonymous.\n")));
+                nResult = -1;
+            }
+            else
+            {
+                ACE_DEBUG((LM_INFO, ACE_TEXT("Changing password for user: %W...\n\n"), m_strUser.c_str()));
+                pService->UpdateUser(m_strUser, L"", L"", m_strPassword, L"");
+                ACE_DEBUG((LM_INFO, ACE_TEXT("Password changed.\n")));
+            }
+        }
+    }
+    catch (MgException* e)
+    {
+        ACE_DEBUG((LM_ERROR, ACE_TEXT("Unable to load the specified package.\n")));
+        ACE_DEBUG((LM_ERROR, ACE_TEXT("%W\n"), e->GetStackTrace(m_locale).c_str()));
+        SAFE_RELEASE(e);
+
+        nResult = -1;
+    }
+    catch (...)
+    {
+        ACE_DEBUG((LM_ERROR, ACE_TEXT("Unable to load the specified package.\n")));
+
+        nResult = -1;
+    }
+
+    return nResult;
+}

Copied: trunk/MgDev/Server/src/Core/SetPwdCommand.h (from rev 9217, sandbox/jng/cmdline/Server/src/Core/SetPwdCommand.h)
===================================================================
--- trunk/MgDev/Server/src/Core/SetPwdCommand.h	                        (rev 0)
+++ trunk/MgDev/Server/src/Core/SetPwdCommand.h	2017-06-21 15:53:47 UTC (rev 9218)
@@ -0,0 +1,38 @@
+//
+//  Copyright (C) 2004-2017 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 SET_PWD_COMMAND_H
+#define SET_PWD_COMMAND_H
+
+#include "MapGuideCommon.h"
+#include "ServerInteractiveCommand.h"
+
+class MgSetPwdCommand : public MgServerInteractiveCommand
+{
+public:
+    MgSetPwdCommand(CREFSTRING locale, CREFSTRING userName, CREFSTRING password);
+    virtual ~MgSetPwdCommand();
+
+    virtual INT32 Execute();
+
+private:
+    STRING m_locale;
+    STRING m_strUser;
+    STRING m_strPassword;
+};
+
+#endif
\ No newline at end of file

Copied: trunk/MgDev/Server/src/Core/TestCommand.cpp (from rev 9217, sandbox/jng/cmdline/Server/src/Core/TestCommand.cpp)
===================================================================
--- trunk/MgDev/Server/src/Core/TestCommand.cpp	                        (rev 0)
+++ trunk/MgDev/Server/src/Core/TestCommand.cpp	2017-06-21 15:53:47 UTC (rev 9218)
@@ -0,0 +1,126 @@
+#include "LogManager.h"
+#include "TestCommand.h"
+
+MgTestCommand::MgTestCommand(CREFSTRING locale, CREFSTRING subSuite, CREFSTRING outputFile)
+    : MgServerInteractiveCommand()
+{
+    m_locale = locale;
+    m_subSuite = subSuite;
+    m_outputFile = outputFile;
+}
+
+MgTestCommand::~MgTestCommand()
+{
+}
+
+INT32 MgTestCommand::Execute()
+{
+    INT32 nResult = 0;
+
+    // Run the test cases
+
+    typedef int(*EXECUTE)(CREFSTRING, CREFSTRING);
+
+    MG_LOG_TRACE_ENTRY(L"MgTestCommand::Execute() - Running the server unit tests.");
+    ACE_DEBUG((LM_INFO, ACE_TEXT("Preparing to run the unit tests...\n\n")));
+
+    try
+    {
+        // Let the site manager know that the check servers background thread needs to stop
+        MgSiteManager* siteManager = MgSiteManager::GetInstance();
+        siteManager->StopCheckServersThread();
+
+        // Change the log file names to use the unit test names because we don't want to replace the existing log files
+        MgLogManager* pLogManager = MgLogManager::GetInstance();
+        STRING filename;
+
+        filename = L"Test" + MgLogManager::DefaultAccessLogFileName;
+        pLogManager->SetAccessLogFileName(filename);
+
+        filename = L"Test" + MgLogManager::DefaultAdminLogFileName;
+        pLogManager->SetAdminLogFileName(filename);
+
+        filename = L"Test" + MgLogManager::DefaultAuthenticationLogFileName;
+        pLogManager->SetAuthenticationLogFileName(filename);
+
+        filename = L"Test" + MgLogManager::DefaultErrorLogFileName;
+        pLogManager->SetErrorLogFileName(filename);
+
+        filename = L"Test" + MgLogManager::DefaultSessionLogFileName;
+        pLogManager->SetSessionLogFileName(filename);
+
+        filename = L"Test" + MgLogManager::DefaultTraceLogFileName;
+        pLogManager->SetTraceLogFileName(filename);
+
+        EXECUTE execute = NULL;
+
+#ifdef _WIN32
+        HMODULE hlib = NULL;
+#ifdef _DEBUG // load debug dll
+        STRING library = L"MgUnitTestingd.dll";
+        hlib = LoadLibrary(library.c_str());
+#else // Load Release dll
+        STRING library = L"MgUnitTesting.dll";
+        hlib = LoadLibrary(library.c_str());
+#endif
+
+        if (hlib != NULL)
+        {
+            execute = (EXECUTE)GetProcAddress(hlib, "Execute");
+        }
+        else
+        {
+            ACE_DEBUG((LM_INFO, ACE_TEXT("Cannot open library: %W\n"), library.c_str()));
+            throw new MgUnclassifiedException(L"MgTestCommand.Execute", __LINE__, __WFILE__, NULL, L"", NULL);
+        }
+#else
+        string library = "libMgUnitTesting.so";
+        void* hlib = dlopen(library.c_str(), RTLD_NOW);
+
+        if (hlib != NULL)
+        {
+            execute = (EXECUTE)dlsym(hlib, "Execute");
+        }
+        else
+        {
+            ACE_DEBUG((LM_INFO, ACE_TEXT("Cannot open library: %s\n"), library.c_str()));
+            throw new MgUnclassifiedException(L"MgTestCommand.Execute", __LINE__, __WFILE__, NULL, L"", NULL);
+        }
+#endif // _WIN32
+        if (execute != NULL)
+        {
+            nResult = (*execute)(m_outputFile, m_subSuite);
+
+            // The build script does not work with negative return codes, which is what is returned on a failure from CPPUnit.
+            // Therefore, we change the -1 result to a positive 1 to indicate to the build script that an error occurred.
+            if (nResult < 0)
+            {
+                nResult = -(nResult);
+            }
+        }
+        else
+        {
+            // Failed to retrieve function
+            ACE_DEBUG((LM_INFO, ACE_TEXT("Cannot locate 'Execute' procedure address inside library.\n")));
+            throw new MgUnclassifiedException(L"MgTestCommand.Execute", __LINE__, __WFILE__, NULL, L"", NULL);
+        }
+
+        ACE_DEBUG((LM_INFO, ACE_TEXT("Finished running the unit tests.\n\n")));
+    }
+    catch (MgException* e)
+    {
+        ACE_DEBUG((LM_ERROR, ACE_TEXT("Unable to run all the unit tests.\n")));
+        ACE_DEBUG((LM_ERROR, ACE_TEXT("%W\n"), e->GetStackTrace(m_locale).c_str()));
+        SAFE_RELEASE(e);
+
+        nResult = -1;
+    }
+    catch (...)
+    {
+        ACE_DEBUG((LM_ERROR, ACE_TEXT("Unable to run all the unit tests.\n")));
+
+        nResult = -1;
+    }
+
+    return nResult;
+}
\ No newline at end of file

Copied: trunk/MgDev/Server/src/Core/TestCommand.h (from rev 9217, sandbox/jng/cmdline/Server/src/Core/TestCommand.h)
===================================================================
--- trunk/MgDev/Server/src/Core/TestCommand.h	                        (rev 0)
+++ trunk/MgDev/Server/src/Core/TestCommand.h	2017-06-21 15:53:47 UTC (rev 9218)
@@ -0,0 +1,39 @@
+//
+//  Copyright (C) 2004-2017 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 TEST_COMMAND_H
+#define TEST_COMMAND_H
+
+#include "MapGuideCommon.h"
+#include "ServerInteractiveCommand.h"
+
+class MgTestCommand : public MgServerInteractiveCommand
+{
+public:
+    MgTestCommand(CREFSTRING locale, CREFSTRING subSuite, CREFSTRING outputFile);
+    virtual ~MgTestCommand();
+
+    virtual INT32 Execute();
+
+private:
+    STRING m_locale;
+    STRING m_subSuite;
+    STRING m_outputFile;
+};
+
+#endif
+

Copied: trunk/MgDev/Server/src/Core/TestFdoCommand.cpp (from rev 9217, sandbox/jng/cmdline/Server/src/Core/TestFdoCommand.cpp)
===================================================================
--- trunk/MgDev/Server/src/Core/TestFdoCommand.cpp	                        (rev 0)
+++ trunk/MgDev/Server/src/Core/TestFdoCommand.cpp	2017-06-21 15:53:47 UTC (rev 9218)
@@ -0,0 +1,125 @@
+#include "LogManager.h"
+#include "TestFdoCommand.h"
+
+MgTestFdoCommand::MgTestFdoCommand(CREFSTRING locale, CREFSTRING outputFile)
+    : MgServerInteractiveCommand()
+{
+    m_locale = locale;
+    m_outputFile = outputFile;
+}
+
+MgTestFdoCommand::~MgTestFdoCommand()
+{
+}
+
+INT32 MgTestFdoCommand::Execute()
+{
+    INT32 nResult = 0;
+
+    // Run the FDO test cases
+
+    typedef int(*EXECUTE)(CREFSTRING);
+
+    MG_LOG_TRACE_ENTRY(L"MgTestFdoCommand::Execute() - Running the FDO unit tests.");
+    ACE_DEBUG((LM_INFO, ACE_TEXT("Preparing to run the FDO unit tests...\n\n")));
+
+    try
+    {
+        // Let the site manager know that the check servers background thread needs to stop
+        MgSiteManager* siteManager = MgSiteManager::GetInstance();
+        siteManager->StopCheckServersThread();
+
+        // Change the log file names to use the unit test names because we don't want to replace the existing log files
+        MgLogManager* pLogManager = MgLogManager::GetInstance();
+        STRING filename;
+
+        filename = L"Test" + MgLogManager::DefaultAccessLogFileName;
+        pLogManager->SetAccessLogFileName(filename);
+
+        filename = L"Test" + MgLogManager::DefaultAdminLogFileName;
+        pLogManager->SetAdminLogFileName(filename);
+
+        filename = L"Test" + MgLogManager::DefaultAuthenticationLogFileName;
+        pLogManager->SetAuthenticationLogFileName(filename);
+
+        filename = L"Test" + MgLogManager::DefaultErrorLogFileName;
+        pLogManager->SetErrorLogFileName(filename);
+
+        filename = L"Test" + MgLogManager::DefaultSessionLogFileName;
+        pLogManager->SetSessionLogFileName(filename);
+
+        filename = L"Test" + MgLogManager::DefaultTraceLogFileName;
+        pLogManager->SetTraceLogFileName(filename);
+
+        EXECUTE execute = NULL;
+
+#ifdef _WIN32
+        HMODULE hlib = NULL;
+#ifdef _DEBUG // load debug dll
+        STRING library = L"MgFdoUnitTestingd.dll";
+        hlib = LoadLibrary(library.c_str());
+#else // Load Release dll
+        STRING library = L"MgFdoUnitTesting.dll";
+        hlib = LoadLibrary(library.c_str());
+#endif
+
+        if (hlib != NULL)
+        {
+            execute = (EXECUTE)GetProcAddress(hlib, "Execute");
+        }
+        else
+        {
+            ACE_DEBUG((LM_INFO, ACE_TEXT("Cannot open library: %W\n"), library.c_str()));
+            throw new MgUnclassifiedException(L"MgTestFdoCommand.Execute", __LINE__, __WFILE__, NULL, L"", NULL);
+        }
+#else
+        string library = "libMgFdoUnitTesting.so";
+        void* hlib = dlopen(library.c_str(), RTLD_NOW);
+
+        if (hlib != NULL)
+        {
+            execute = (EXECUTE)dlsym(hlib, "Execute");
+        }
+        else
+        {
+            ACE_DEBUG((LM_INFO, ACE_TEXT("Cannot open library: %s\n"), library.c_str()));
+            throw new MgUnclassifiedException(L"MgTestFdoCommand.Execute", __LINE__, __WFILE__, NULL, L"", NULL);
+        }
+#endif // _WIN32
+        if (execute != NULL)
+        {
+            nResult = (*execute)(m_outputFile);
+
+            // The build script does not work with negative return codes, which is what is returned on a failure from CPPUnit.
+            // Therefore, we change the -1 result to a positive 1 to indicate to the build script that an error occurred.
+            if (nResult < 0)
+            {
+                nResult = -(nResult);
+            }
+        }
+        else
+        {
+            // Failed to retrieve function
+            ACE_DEBUG((LM_INFO, ACE_TEXT("Cannot locate 'Execute' procedure address inside library.\n")));
+            throw new MgUnclassifiedException(L"MgTestFdoCommand.Execute", __LINE__, __WFILE__, NULL, L"", NULL);
+        }
+
+        ACE_DEBUG((LM_INFO, ACE_TEXT("Finished running the FDO unit tests.\n")));
+    }
+    catch (MgException* e)
+    {
+        ACE_DEBUG((LM_ERROR, ACE_TEXT("Unable to run all the FDO unit tests.\n")));
+        ACE_DEBUG((LM_ERROR, ACE_TEXT("%W\n"), e->GetStackTrace(m_locale).c_str()));
+        SAFE_RELEASE(e);
+
+        nResult = -1;
+    }
+    catch (...)
+    {
+        ACE_DEBUG((LM_ERROR, ACE_TEXT("Unable to run all the FDO unit tests.\n")));
+
+        nResult = -1;
+    }
+
+    return nResult;
+}

Copied: trunk/MgDev/Server/src/Core/TestFdoCommand.h (from rev 9217, sandbox/jng/cmdline/Server/src/Core/TestFdoCommand.h)
===================================================================
--- trunk/MgDev/Server/src/Core/TestFdoCommand.h	                        (rev 0)
+++ trunk/MgDev/Server/src/Core/TestFdoCommand.h	2017-06-21 15:53:47 UTC (rev 9218)
@@ -0,0 +1,37 @@
+//
+//  Copyright (C) 2004-2017 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 TEST_FDO_COMMAND_H
+#define TEST_FDO_COMMAND_H
+
+#include "MapGuideCommon.h"
+#include "ServerInteractiveCommand.h"
+
+class MgTestFdoCommand : public MgServerInteractiveCommand
+{
+public:
+    MgTestFdoCommand(CREFSTRING locale, CREFSTRING outputFile);
+    virtual ~MgTestFdoCommand();
+
+    virtual INT32 Execute();
+
+private:
+    STRING m_locale;
+    STRING m_outputFile;
+};
+
+#endif
\ No newline at end of file

Modified: trunk/MgDev/Server/src/Core/main.cpp
===================================================================
--- trunk/MgDev/Server/src/Core/main.cpp	2017-06-15 16:13:06 UTC (rev 9217)
+++ trunk/MgDev/Server/src/Core/main.cpp	2017-06-21 15:53:47 UTC (rev 9218)
@@ -294,6 +294,36 @@
 
                 bRunServerService = false;
             }
+            else if (ACE_OS::strcasecmp(parameter, MG_WCHAR_TO_TCHAR(MgResources::ServerCmdLoadPackage)) == 0)
+            {
+                // Run the package loading
+                ACE_OS::printf(MG_WCHAR_TO_CHAR(MgResources::ServerCmdLoadPackageInfo));
+
+                // Run the server as a regular application
+                nResult = SERVER::instance()->init(argc, argv);
+                if (0 == nResult)
+                {
+                    nResult = SERVER::instance()->open();
+                    SERVER::instance()->fini();
+                }
+
+                bRunServerService = false;
+            }
+            else if (ACE_OS::strcasecmp(parameter, MG_WCHAR_TO_TCHAR(MgResources::ServerCmdSetPwd)) == 0)
+            {
+                // Run the password setting
+                ACE_OS::printf(MG_WCHAR_TO_CHAR(MgResources::ServerCmdSetPwdInfo));
+
+                // Run the server as a regular application
+                nResult = SERVER::instance()->init(argc, argv);
+                if (0 == nResult)
+                {
+                    nResult = SERVER::instance()->open();
+                    SERVER::instance()->fini();
+                }
+
+                bRunServerService = false;
+            }
             else
             {
                 // Unrecognized command line option
@@ -419,6 +449,8 @@
     // Add the supported commands
     ACE_OS::printf(MG_WCHAR_TO_CHAR(MgResources::ServerCmdTestFdoDescription));
     ACE_OS::printf(MG_WCHAR_TO_CHAR(MgResources::ServerCmdTestDescription));
+    ACE_OS::printf(MG_WCHAR_TO_CHAR(MgResources::ServerCmdLoadPackageDescription));
+    ACE_OS::printf(MG_WCHAR_TO_CHAR(MgResources::ServerCmdSetPwdDescription));
 
 #ifdef _WIN32
     // Windows only commands



More information about the mapguide-commits mailing list