[mapguide-commits] r9657 - sandbox/jng/catch2/Server/src/UnitTesting
svn_mapguide at osgeo.org
svn_mapguide at osgeo.org
Wed Jul 8 04:10:17 PDT 2020
Author: jng
Date: 2020-07-08 04:10:16 -0700 (Wed, 08 Jul 2020)
New Revision: 9657
Removed:
sandbox/jng/catch2/Server/src/UnitTesting/TestDrawingService.h
sandbox/jng/catch2/Server/src/UnitTesting/TestKmlService.h
sandbox/jng/catch2/Server/src/UnitTesting/TestLogManager.h
sandbox/jng/catch2/Server/src/UnitTesting/TestMappingService.h
Modified:
sandbox/jng/catch2/Server/src/UnitTesting/TestDrawingService.cpp
sandbox/jng/catch2/Server/src/UnitTesting/TestKmlService.cpp
sandbox/jng/catch2/Server/src/UnitTesting/TestLogManager.cpp
sandbox/jng/catch2/Server/src/UnitTesting/TestMappingService.cpp
sandbox/jng/catch2/Server/src/UnitTesting/UnitTesting.vcxproj
Log:
Port drawing, mapping, kml and log manager tests to catch2
Modified: sandbox/jng/catch2/Server/src/UnitTesting/TestDrawingService.cpp
===================================================================
--- sandbox/jng/catch2/Server/src/UnitTesting/TestDrawingService.cpp 2020-07-07 15:57:41 UTC (rev 9656)
+++ sandbox/jng/catch2/Server/src/UnitTesting/TestDrawingService.cpp 2020-07-08 11:10:16 UTC (rev 9657)
@@ -16,100 +16,25 @@
//
#include "MapGuideCommon.h"
-#include "TestDrawingService.h"
-#include "CppUnitExtensions.h"
+#include "CatchHelperMacros.h"
#include "ServiceManager.h"
+#include "TestServiceFactory.h"
+#include "catch.hpp"
-const STRING TEST_LOCALE = L"en";
-
-CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(TestDrawingService, "TestDrawingService");
-
-TestDrawingService::TestDrawingService()
+TEST_CASE("DescribeDrawing", "[DrawingService]")
{
- // Initialize service objects.
- MgServiceManager* serviceManager = MgServiceManager::GetInstance();
-
- m_svcDrawing = dynamic_cast<MgDrawingService*>(serviceManager->RequestService(MgServiceType::DrawingService));
- assert(m_svcDrawing != NULL);
-}
-
-TestDrawingService::~TestDrawingService() { }
-
-void TestDrawingService::setUp() { }
-
-void TestDrawingService::tearDown() { }
-
-void TestDrawingService::TestStart()
-{
try
{
- MgServiceManager* serviceManager = MgServiceManager::GetInstance();
- Ptr<MgResourceService> resSvc = dynamic_cast<MgResourceService*>(serviceManager->RequestService(MgServiceType::ResourceService));
- assert(resSvc != NULL);
-
- //Set the user information for the current thread to be administrator
- MgUserInformation::SetCurrentUserInfo(NULL);
- Ptr<MgUserInformation> userInfo = new MgUserInformation(L"Administrator", L"admin");
- userInfo->SetLocale(TEST_LOCALE);
- MgUserInformation::SetCurrentUserInfo(userInfo);
-
- MgResourceIdentifier resourceIdentifier1(L"Library://UnitTests/Drawings/SpaceShip.DrawingSource");
-
- Ptr<MgByteSource> contentSource1 = new MgByteSource(L"../UnitTestFiles/SpaceShipDrawingSource.xml");
- Ptr<MgByteReader> contentReader1 = contentSource1->GetReader();
- resSvc->SetResource(&resourceIdentifier1, contentReader1, NULL);
-
- Ptr<MgByteSource> dataSource1 = new MgByteSource(L"../UnitTestFiles/SpaceShip.dwf");
- Ptr<MgByteReader> dataReader1 = dataSource1->GetReader();
- resSvc->SetResourceData(&resourceIdentifier1, L"SpaceShip.dwf", L"File", dataReader1);
- }
- catch(MgException* e)
- {
- STRING message = e->GetDetails(TEST_LOCALE);
- SAFE_RELEASE(e);
- CPPUNIT_FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
- }
-}
-
-void TestDrawingService::TestEnd()
-{
- try
- {
- MgServiceManager* serviceManager = MgServiceManager::GetInstance();
- Ptr<MgResourceService> resSvc = dynamic_cast<MgResourceService*>(serviceManager->RequestService(MgServiceType::ResourceService));
- assert(resSvc != NULL);
-
- //Set the user information for the current thread to be administrator
- MgUserInformation::SetCurrentUserInfo(NULL);
- Ptr<MgUserInformation> userInfo = new MgUserInformation(L"Administrator", L"admin");
- userInfo->SetLocale(TEST_LOCALE);
- MgUserInformation::SetCurrentUserInfo(userInfo);
-
- MgResourceIdentifier resourceIdentifier1(L"Library://UnitTests/Drawings/SpaceShip.DrawingSource");
-
- resSvc->DeleteResource(&resourceIdentifier1);
- }
- catch(MgException* e)
- {
- STRING message = e->GetDetails(TEST_LOCALE);
- SAFE_RELEASE(e);
- CPPUNIT_FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
- }
-}
-
-void TestDrawingService::TestCase_DescribeDrawing()
-{
- try
- {
+ Ptr<MgDrawingService> m_svcDrawing = TestServiceFactory::CreateDrawingService();
Ptr<MgResourceIdentifier> resId1 = new MgResourceIdentifier(L"Library://UnitTests/Drawings/SpaceShip.DrawingSource");
Ptr<MgByteReader> rdr1 = m_svcDrawing->DescribeDrawing(resId1);
- CPPUNIT_ASSERT(MgMimeType::Xml == rdr1->GetMimeType());
+ REQUIRE(MgMimeType::Xml == rdr1->GetMimeType());
}
catch (MgException* e)
{
- STRING message = e->GetDetails(TEST_LOCALE);
+ STRING message = e->GetDetails(TestServiceFactory::TEST_LOCALE);
SAFE_RELEASE(e);
- CPPUNIT_FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
+ FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
}
catch (...)
{
@@ -117,19 +42,20 @@
}
}
-void TestDrawingService::TestCase_EnumerateSections()
+TEST_CASE("EnumerateSections", "[DrawingService]")
{
try
{
+ Ptr<MgDrawingService> m_svcDrawing = TestServiceFactory::CreateDrawingService();
Ptr<MgResourceIdentifier> resId1 = new MgResourceIdentifier(L"Library://UnitTests/Drawings/SpaceShip.DrawingSource");
Ptr<MgByteReader> rdr1 = m_svcDrawing->EnumerateSections(resId1);
- CPPUNIT_ASSERT(MgMimeType::Xml == rdr1->GetMimeType());
+ REQUIRE(MgMimeType::Xml == rdr1->GetMimeType());
}
catch (MgException* e)
{
- STRING message = e->GetDetails(TEST_LOCALE);
+ STRING message = e->GetDetails(TestServiceFactory::TEST_LOCALE);
SAFE_RELEASE(e);
- CPPUNIT_FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
+ FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
}
catch (...)
{
@@ -137,22 +63,23 @@
}
}
-void TestDrawingService::TestCase_EnumerateSectionResources()
+TEST_CASE("EnumerateSectionResources", "[DrawingService]")
{
try
{
+ Ptr<MgDrawingService> m_svcDrawing = TestServiceFactory::CreateDrawingService();
Ptr<MgResourceIdentifier> resId1 = new MgResourceIdentifier(L"Library://UnitTests/Drawings/SpaceShip.DrawingSource");
- CPPUNIT_ASSERT_THROW_MG(m_svcDrawing->EnumerateSectionResources(resId1, L"foo"), MgDwfSectionNotFoundException*);
+ REQUIRE_THROWS_MG(m_svcDrawing->EnumerateSectionResources(resId1, L"foo"), MgDwfSectionNotFoundException*);
STRING sect1 = L"com.autodesk.dwf.ePlot_9E2723744244DB8C44482263E654F764";
Ptr<MgByteReader> rdr1 = m_svcDrawing->EnumerateSectionResources(resId1, sect1);
- CPPUNIT_ASSERT(MgMimeType::Xml == rdr1->GetMimeType());
+ REQUIRE(MgMimeType::Xml == rdr1->GetMimeType());
}
catch (MgException* e)
{
- STRING message = e->GetDetails(TEST_LOCALE);
+ STRING message = e->GetDetails(TestServiceFactory::TEST_LOCALE);
SAFE_RELEASE(e);
- CPPUNIT_FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
+ FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
}
catch (...)
{
@@ -160,19 +87,20 @@
}
}
-void TestDrawingService::TestCase_GetCoordinateSpace()
+TEST_CASE("GetCoordinateSpace", "[DrawingService]")
{
try
{
+ Ptr<MgDrawingService> m_svcDrawing = TestServiceFactory::CreateDrawingService();
Ptr<MgResourceIdentifier> resId1 = new MgResourceIdentifier(L"Library://UnitTests/Drawings/SpaceShip.DrawingSource");
STRING cs1 = m_svcDrawing->GetCoordinateSpace(resId1);
- CPPUNIT_ASSERT(!cs1.empty());
+ REQUIRE(!cs1.empty());
}
catch (MgException* e)
{
- STRING message = e->GetDetails(TEST_LOCALE);
+ STRING message = e->GetDetails(TestServiceFactory::TEST_LOCALE);
SAFE_RELEASE(e);
- CPPUNIT_FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
+ FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
}
catch (...)
{
@@ -180,20 +108,21 @@
}
}
-void TestDrawingService::TestCase_EnumerateLayers()
+TEST_CASE("EnumerateLayers", "[DrawingService]")
{
try
{
+ Ptr<MgDrawingService> m_svcDrawing = TestServiceFactory::CreateDrawingService();
Ptr<MgResourceIdentifier> resId1 = new MgResourceIdentifier(L"Library://UnitTests/Drawings/SpaceShip.DrawingSource");
STRING sect1 = L"com.autodesk.dwf.ePlot_9E2723744244DB8C44482263E654F764";
Ptr<MgStringCollection> str1 = m_svcDrawing->EnumerateLayers(resId1, sect1);
- CPPUNIT_ASSERT(str1->GetCount() > 0);
+ REQUIRE(str1->GetCount() > 0);
}
catch (MgException* e)
{
- STRING message = e->GetDetails(TEST_LOCALE);
+ STRING message = e->GetDetails(TestServiceFactory::TEST_LOCALE);
SAFE_RELEASE(e);
- CPPUNIT_FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
+ FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
}
catch (...)
{
@@ -201,19 +130,20 @@
}
}
-void TestDrawingService::TestCase_GetDrawing()
+TEST_CASE("GetDrawing", "[DrawingService]")
{
try
{
+ Ptr<MgDrawingService> m_svcDrawing = TestServiceFactory::CreateDrawingService();
Ptr<MgResourceIdentifier> resId1 = new MgResourceIdentifier(L"Library://UnitTests/Drawings/SpaceShip.DrawingSource");
Ptr<MgByteReader> rdr1 = m_svcDrawing->GetDrawing(resId1);
- CPPUNIT_ASSERT(NULL != rdr1.p);
+ REQUIRE(NULL != rdr1.p);
}
catch (MgException* e)
{
- STRING message = e->GetDetails(TEST_LOCALE);
+ STRING message = e->GetDetails(TestServiceFactory::TEST_LOCALE);
SAFE_RELEASE(e);
- CPPUNIT_FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
+ FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
}
catch (...)
{
@@ -221,10 +151,11 @@
}
}
-void TestDrawingService::TestCase_GetLayer()
+TEST_CASE("GetLayer", "[DrawingService]")
{
try
{
+ Ptr<MgDrawingService> m_svcDrawing = TestServiceFactory::CreateDrawingService();
Ptr<MgResourceIdentifier> resId1 = new MgResourceIdentifier(L"Library://UnitTests/Drawings/SpaceShip.DrawingSource");
STRING sect1 = L"com.autodesk.dwf.ePlot_9E2723744244DB8C44482263E654F764";
Ptr<MgStringCollection> dwfLayers = m_svcDrawing->EnumerateLayers(resId1, sect1);
@@ -235,9 +166,9 @@
}
catch (MgException* e)
{
- STRING message = e->GetDetails(TEST_LOCALE);
+ STRING message = e->GetDetails(TestServiceFactory::TEST_LOCALE);
SAFE_RELEASE(e);
- CPPUNIT_FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
+ FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
}
catch (...)
{
@@ -245,10 +176,11 @@
}
}
-void TestDrawingService::TestCase_GetSection()
+TEST_CASE("GetSection", "[DrawingService]")
{
try
{
+ Ptr<MgDrawingService> m_svcDrawing = TestServiceFactory::CreateDrawingService();
Ptr<MgResourceIdentifier> resId1 = new MgResourceIdentifier(L"Library://UnitTests/Drawings/SpaceShip.DrawingSource");
STRING sect1 = L"com.autodesk.dwf.ePlot_9E2723744244DB8C44482263E654F764";
Ptr<MgByteReader> rdr = m_svcDrawing->GetSection(resId1, sect1);
@@ -255,9 +187,9 @@
}
catch (MgException* e)
{
- STRING message = e->GetDetails(TEST_LOCALE);
+ STRING message = e->GetDetails(TestServiceFactory::TEST_LOCALE);
SAFE_RELEASE(e);
- CPPUNIT_FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
+ FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
}
catch (...)
{
@@ -265,23 +197,24 @@
}
}
-void TestDrawingService::TestCase_GetSectionResource()
+TEST_CASE("GetSectionResource", "[DrawingService]")
{
try
{
+ Ptr<MgDrawingService> m_svcDrawing = TestServiceFactory::CreateDrawingService();
Ptr<MgResourceIdentifier> resId1 = new MgResourceIdentifier(L"Library://UnitTests/Drawings/SpaceShip.DrawingSource");
STRING res1 = L"com.autodesk.dwf.ePlot_9E2723744244DB8C44482263E654F764\\4AA701C2E18DD99948F3C0D4FDFAC165.png";
Ptr<MgByteReader> rdr1 = m_svcDrawing->GetSectionResource(resId1, res1);
- CPPUNIT_ASSERT(rdr1->GetMimeType() == MgMimeType::Png);
+ REQUIRE(rdr1->GetMimeType() == MgMimeType::Png);
STRING res2 = L"com.autodesk.dwf.ePlot_9E2723744244DB8C44482263E654F764\\descriptor.xml";
Ptr<MgByteReader> rdr2 = m_svcDrawing->GetSectionResource(resId1, res2);
- CPPUNIT_ASSERT(rdr2->GetMimeType() == MgMimeType::Xml);
+ REQUIRE(rdr2->GetMimeType() == MgMimeType::Xml);
}
catch (MgException* e)
{
- STRING message = e->GetDetails(TEST_LOCALE);
+ STRING message = e->GetDetails(TestServiceFactory::TEST_LOCALE);
SAFE_RELEASE(e);
- CPPUNIT_FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
+ FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
}
catch (...)
{
Deleted: sandbox/jng/catch2/Server/src/UnitTesting/TestDrawingService.h
===================================================================
--- sandbox/jng/catch2/Server/src/UnitTesting/TestDrawingService.h 2020-07-07 15:57:41 UTC (rev 9656)
+++ sandbox/jng/catch2/Server/src/UnitTesting/TestDrawingService.h 2020-07-08 11:10:16 UTC (rev 9657)
@@ -1,64 +0,0 @@
-//
-// Copyright (C) 2004-2014 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 _TESTDRAWINGSERVICE_H
-#define _TESTDRAWINGSERVICE_H
-
-#include <cppunit/extensions/HelperMacros.h>
-
-class TestDrawingService : public CppUnit::TestFixture
-{
- CPPUNIT_TEST_SUITE(TestDrawingService);
- CPPUNIT_TEST(TestStart); // This must be the very first unit test
-
- CPPUNIT_TEST(TestCase_DescribeDrawing);
- CPPUNIT_TEST(TestCase_EnumerateSections);
- CPPUNIT_TEST(TestCase_EnumerateSectionResources);
- CPPUNIT_TEST(TestCase_GetCoordinateSpace);
- CPPUNIT_TEST(TestCase_EnumerateLayers);
- CPPUNIT_TEST(TestCase_GetDrawing);
- CPPUNIT_TEST(TestCase_GetLayer);
- CPPUNIT_TEST(TestCase_GetSection);
- CPPUNIT_TEST(TestCase_GetSectionResource);
-
- CPPUNIT_TEST(TestEnd); // This must be the very last unit test
- CPPUNIT_TEST_SUITE_END();
-
-public:
- TestDrawingService();
- ~TestDrawingService();
-
- void setUp();
- void tearDown();
- void TestStart();
- void TestEnd();
-
- void TestCase_DescribeDrawing();
- void TestCase_EnumerateSections();
- void TestCase_EnumerateSectionResources();
- void TestCase_GetCoordinateSpace();
- void TestCase_EnumerateLayers();
- void TestCase_GetDrawing();
- void TestCase_GetLayer();
- void TestCase_GetSection();
- void TestCase_GetSectionResource();
-
-private:
- Ptr<MgDrawingService> m_svcDrawing;
-};
-
-#endif // _TESTDRAWINGSERVICE_H
Modified: sandbox/jng/catch2/Server/src/UnitTesting/TestKmlService.cpp
===================================================================
--- sandbox/jng/catch2/Server/src/UnitTesting/TestKmlService.cpp 2020-07-07 15:57:41 UTC (rev 9656)
+++ sandbox/jng/catch2/Server/src/UnitTesting/TestKmlService.cpp 2020-07-08 11:10:16 UTC (rev 9657)
@@ -16,213 +16,104 @@
//
#include "MapGuideCommon.h"
-#include "TestKmlService.h"
#include "ServiceManager.h"
#include "ServerResourceService.h"
#include "ServerSiteService.h"
-#include "../Common/Manager/FdoConnectionManager.h"
#include "FoundationDefs.h"
-const STRING TEST_LOCALE = L"en";
+#include "TestServiceFactory.h"
+#include "catch.hpp"
-CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(TestKmlService, "TestKmlService");
-
-
-TestKmlService::TestKmlService()
+static STRING RemoveSessionIds(CREFSTRING content)
{
- // Initialize service objects.
- MgServiceManager* serviceManager = MgServiceManager::GetInstance();
+ STRING newContent = content;
- m_svcResource = dynamic_cast<MgResourceService*>(
- serviceManager->RequestService(MgServiceType::ResourceService));
- assert(m_svcResource != NULL);
+ STRING sessionId;
+ Ptr<MgUserInformation> userInfo = MgUserInformation::GetCurrentUserInfo();
+ if (userInfo != NULL)
+ {
+ sessionId = userInfo->GetMgSessionId();
+ }
- m_svcKml = dynamic_cast<MgKmlService*>(
- serviceManager->RequestService(MgServiceType::KmlService));
- assert(m_svcKml != NULL);
-
- // Initialize a site connection.
- Ptr<MgServerSiteService> svcSite = dynamic_cast<MgServerSiteService*>(
- serviceManager->RequestService(MgServiceType::SiteService));
- assert(svcSite != NULL);
-
- Ptr<MgUserInformation> userInfo = new MgUserInformation(
- L"Administrator", L"admin");
- userInfo->SetLocale(TEST_LOCALE);
-
- // Set the current MgUserInformation
- // This must be done before calling CreateSession()
- MgUserInformation::SetCurrentUserInfo(userInfo);
-
- STRING session = svcSite->CreateSession();
- assert(!session.empty());
- userInfo->SetMgSessionId(session);
-
- // Set the current MgUserInformation
- MgUserInformation::SetCurrentUserInfo(userInfo);
-
- m_siteConnection = new MgSiteConnection();
- m_siteConnection->Open(userInfo);
+ if (!sessionId.empty())
+ {
+ STRING dummyId = L"SessionIDRemoved";
+ STRING::size_type sessionIdLocation;
+ do
+ {
+ sessionIdLocation = newContent.find(sessionId);
+ if (sessionIdLocation != STRING::npos)
+ {
+ newContent.replace(sessionIdLocation, sessionId.length(), dummyId);
+ }
+ } while (sessionIdLocation != STRING::npos);
+ }
+ return newContent;
}
-TestKmlService::~TestKmlService()
+static void SaveToFile(CREFSTRING content, CREFSTRING filename)
{
+ FILE* file = ACE_OS::fopen(MG_WCHAR_TO_TCHAR(filename), ACE_TEXT("wt"));
+ if (file != NULL)
+ {
+ fwprintf(file, content.c_str());
+ fclose(file);
+ }
}
-void TestKmlService::setUp()
+static STRING LoadFromFile(CREFSTRING filename)
{
-}
-
-
-void TestKmlService::tearDown()
-{
-}
-
-
-void TestKmlService::TestStart()
-{
- ACE_DEBUG((LM_INFO, ACE_TEXT("\nRunning Kml Service tests.\n")));
-
- try
+ STRING content;
+ FILE* file = ACE_OS::fopen(MG_WCHAR_TO_TCHAR(filename), ACE_TEXT("rt"));
+ if (file != NULL)
{
- #ifdef _DEBUG
- MgFdoConnectionManager* pFdoConnectionManager = MgFdoConnectionManager::GetInstance();
- if(pFdoConnectionManager)
+ wchar_t buffer[1024];
+ while (fgetws(buffer, 1024, file) != NULL)
{
- pFdoConnectionManager->ShowCache();
+ content.append(buffer);
}
- #endif
-
- //set user info
- Ptr<MgUserInformation> userInfo = new MgUserInformation(L"Administrator", L"admin");
- userInfo->SetLocale(TEST_LOCALE);
- MgUserInformation::SetCurrentUserInfo(userInfo);
-
- //publish the map definition
- Ptr<MgResourceIdentifier> mapres = new MgResourceIdentifier(L"Library://UnitTests/Maps/Sheboygan.MapDefinition");
- Ptr<MgByteSource> mdfsrc = new MgByteSource(L"../UnitTestFiles/UT_Sheboygan.mdf", false);
- Ptr<MgByteReader> mdfrdr = mdfsrc->GetReader();
- m_svcResource->SetResource(mapres, mdfrdr, NULL);
-
- //publish the layer definitions
- Ptr<MgResourceIdentifier> ldfres1 = new MgResourceIdentifier(L"Library://UnitTests/Layers/HydrographicPolygons.LayerDefinition");
- Ptr<MgByteSource> ldfsrc1 = new MgByteSource(L"../UnitTestFiles/UT_HydrographicPolygons.ldf", false);
- Ptr<MgByteReader> ldfrdr1 = ldfsrc1->GetReader();
- m_svcResource->SetResource(ldfres1, ldfrdr1, NULL);
-
- Ptr<MgResourceIdentifier> ldfres2 = new MgResourceIdentifier(L"Library://UnitTests/Layers/Parcels.LayerDefinition");
- Ptr<MgByteSource> ldfsrc2 = new MgByteSource(L"../UnitTestFiles/UT_Parcels.ldf", false);
- Ptr<MgByteReader> ldfrdr2 = ldfsrc2->GetReader();
- m_svcResource->SetResource(ldfres2, ldfrdr2, NULL);
-
- Ptr<MgResourceIdentifier> ldfres3 = new MgResourceIdentifier(L"Library://UnitTests/Layers/Rail.LayerDefinition");
- Ptr<MgByteSource> ldfsrc3 = new MgByteSource(L"../UnitTestFiles/UT_Rail.ldf", false);
- Ptr<MgByteReader> ldfrdr3 = ldfsrc3->GetReader();
- m_svcResource->SetResource(ldfres3, ldfrdr3, NULL);
-
- //publish the feature sources
- Ptr<MgResourceIdentifier> fsres1 = new MgResourceIdentifier(L"Library://UnitTests/Data/HydrographicPolygons.FeatureSource");
- Ptr<MgByteSource> fssrc1 = new MgByteSource(L"../UnitTestFiles/UT_HydrographicPolygons.fs", false);
- Ptr<MgByteReader> fsrdr1 = fssrc1->GetReader();
- m_svcResource->SetResource(fsres1, fsrdr1, NULL);
-
- Ptr<MgResourceIdentifier> fsres2 = new MgResourceIdentifier(L"Library://UnitTests/Data/Parcels.FeatureSource");
- Ptr<MgByteSource> fssrc2 = new MgByteSource(L"../UnitTestFiles/UT_Parcels.fs", false);
- Ptr<MgByteReader> fsrdr2 = fssrc2->GetReader();
- m_svcResource->SetResource(fsres2, fsrdr2, NULL);
-
- Ptr<MgResourceIdentifier> fsres3 = new MgResourceIdentifier(L"Library://UnitTests/Data/Rail.FeatureSource");
- Ptr<MgByteSource> fssrc3 = new MgByteSource(L"../UnitTestFiles/UT_Rail.fs", false);
- Ptr<MgByteReader> fsrdr3 = fssrc3->GetReader();
- m_svcResource->SetResource(fsres3, fsrdr3, NULL);
-
- // publish the resource data
- Ptr<MgByteSource> dataSource1 = new MgByteSource(L"../UnitTestFiles/UT_HydrographicPolygons.sdf", false);
- Ptr<MgByteReader> dataReader1 = dataSource1->GetReader();
- m_svcResource->SetResourceData(fsres1, L"UT_HydrographicPolygons.sdf", L"File", dataReader1);
-
- Ptr<MgByteSource> dataSource2 = new MgByteSource(L"../UnitTestFiles/UT_Parcels.sdf", false);
- Ptr<MgByteReader> dataReader2 = dataSource2->GetReader();
- m_svcResource->SetResourceData(fsres2, L"UT_Parcels.sdf", L"File", dataReader2);
-
- Ptr<MgByteSource> dataSource3 = new MgByteSource(L"../UnitTestFiles/UT_Rail.sdf", false);
- Ptr<MgByteReader> dataReader3 = dataSource3->GetReader();
- m_svcResource->SetResourceData(fsres3, L"UT_Rail.sdf", L"File", dataReader3);
+ fclose(file);
}
- catch (MgException* e)
- {
- STRING message = e->GetDetails(TEST_LOCALE);
- SAFE_RELEASE(e);
- CPPUNIT_FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
- }
- catch (...)
- {
- throw;
- }
+ return content;
}
-void TestKmlService::TestEnd()
+static bool CompareContent(MgByteReader* reader, CREFSTRING referenceFile)
{
+ bool match = false;
+ reader->GetByteSource()->SetMimeType(L"text/xml");
+ STRING content = reader->ToString();
+ STRING thisContent = RemoveSessionIds(content);
+
try
{
- //set user info
- Ptr<MgUserInformation> userInfo = new MgUserInformation(L"Administrator", L"admin");
- userInfo->SetLocale(TEST_LOCALE);
- MgUserInformation::SetCurrentUserInfo(userInfo);
-
- //delete the map definition
- Ptr<MgResourceIdentifier> mapres = new MgResourceIdentifier(L"Library://UnitTests/Maps/Sheboygan.MapDefinition");
- m_svcResource->DeleteResource(mapres);
-
- //delete the layer definitions
- Ptr<MgResourceIdentifier> ldfres1 = new MgResourceIdentifier(L"Library://UnitTests/Layers/HydrographicPolygons.LayerDefinition");
- m_svcResource->DeleteResource(ldfres1);
-
- Ptr<MgResourceIdentifier> ldfres2 = new MgResourceIdentifier(L"Library://UnitTests/Layers/Parcels.LayerDefinition");
- m_svcResource->DeleteResource(ldfres2);
-
- Ptr<MgResourceIdentifier> ldfres3 = new MgResourceIdentifier(L"Library://UnitTests/Layers/Rail.LayerDefinition");
- m_svcResource->DeleteResource(ldfres3);
-
- //delete the feature sources
- Ptr<MgResourceIdentifier> fsres1 = new MgResourceIdentifier(L"Library://UnitTests/Data/HydrographicPolygons.FeatureSource");
- m_svcResource->DeleteResource(fsres1);
-
- Ptr<MgResourceIdentifier> fsres2 = new MgResourceIdentifier(L"Library://UnitTests/Data/Parcels.FeatureSource");
- m_svcResource->DeleteResource(fsres2);
-
- Ptr<MgResourceIdentifier> fsres3 = new MgResourceIdentifier(L"Library://UnitTests/Data/Rail.FeatureSource");
- m_svcResource->DeleteResource(fsres3);
-
- #ifdef _DEBUG
- MgFdoConnectionManager* pFdoConnectionManager = MgFdoConnectionManager::GetInstance();
- if(pFdoConnectionManager)
- {
- pFdoConnectionManager->ShowCache();
- }
- #endif
+ STRING referenceContent = LoadFromFile(referenceFile);
+ match = (thisContent.compare(0, thisContent.length(), referenceContent) == 0);
}
- catch (MgException* e)
+ catch (...)
{
- STRING message = e->GetDetails(TEST_LOCALE);
- SAFE_RELEASE(e);
- CPPUNIT_FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
+ match = false;
}
- catch (...)
+
+ //if we didn't get a match, dump out the content we did get
+ if (!match)
{
- throw;
+ STRING errorFile = referenceFile + L".err";
+ SaveToFile(thisContent, errorFile);
}
- ACE_DEBUG((LM_INFO, ACE_TEXT("\nKml Service tests completed.\n\n")));
+ return match;
}
-
-void TestKmlService::TestCase_GetMapKml()
+TEST_CASE("GetMapKml", "[KmlService]")
{
try
{
+ Ptr<MgKmlService> m_svcKml = TestServiceFactory::CreateKmlService();
+ Ptr<MgServerSiteService> svcSite = TestServiceFactory::CreateSiteService();
+ Ptr<MgSiteConnection> m_siteConnection = TestServiceFactory::CreateSiteConnection(svcSite);
+
//create map object
Ptr<MgResourceIdentifier> mdfres = new MgResourceIdentifier(L"Library://UnitTests/Maps/Sheboygan.MapDefinition");
Ptr<MgMap> map = new MgMap(m_siteConnection);
@@ -239,7 +130,7 @@
Ptr<MgByteReader> reader = m_svcKml->GetMapKml(map, dpi, agentUri, format);
STRING mimeType = reader->GetMimeType();
- CPPUNIT_ASSERT(mimeType.compare(MgMimeType::Kml) == 0);
+ REQUIRE(mimeType.compare(MgMimeType::Kml) == 0);
}
catch(MgConnectionFailedException* e)
{
@@ -255,13 +146,13 @@
//compare results against referenced content
//TODO: Find a way to make the comparison work on Windows AND Linux
- //CPPUNIT_ASSERT(CompareContent(reader, L"../UnitTestFiles/UT_GetMapKMLResult.txt"));
+ //REQUIRE(CompareContent(reader, L"../UnitTestFiles/UT_GetMapKMLResult.txt"));
}
catch(MgException* e)
{
- STRING message = e->GetDetails(TEST_LOCALE);
+ STRING message = e->GetDetails(TestServiceFactory::TEST_LOCALE);
SAFE_RELEASE(e);
- CPPUNIT_FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
+ FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
}
catch(...)
{
@@ -269,11 +160,14 @@
}
}
-
-void TestKmlService::TestCase_GetMapKmz()
+TEST_CASE("GetMapKmz", "[KmlService]")
{
try
{
+ Ptr<MgKmlService> m_svcKml = TestServiceFactory::CreateKmlService();
+ Ptr<MgServerSiteService> svcSite = TestServiceFactory::CreateSiteService();
+ Ptr<MgSiteConnection> m_siteConnection = TestServiceFactory::CreateSiteConnection(svcSite);
+
//create map object
Ptr<MgResourceIdentifier> mdfres = new MgResourceIdentifier(L"Library://UnitTests/Maps/Sheboygan.MapDefinition");
Ptr<MgMap> map = new MgMap(m_siteConnection);
@@ -290,7 +184,7 @@
Ptr<MgByteReader> reader = m_svcKml->GetMapKml(map, dpi, agentUri, format);
STRING mimeType = reader->GetMimeType();
- CPPUNIT_ASSERT(mimeType.compare(MgMimeType::Kmz) == 0);
+ REQUIRE(mimeType.compare(MgMimeType::Kmz) == 0);
}
catch(MgConnectionFailedException* e)
{
@@ -306,9 +200,9 @@
}
catch(MgException* e)
{
- STRING message = e->GetDetails(TEST_LOCALE);
+ STRING message = e->GetDetails(TestServiceFactory::TEST_LOCALE);
SAFE_RELEASE(e);
- CPPUNIT_FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
+ FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
}
catch(...)
{
@@ -316,11 +210,13 @@
}
}
-
-void TestKmlService::TestCase_GetLayerKml()
+TEST_CASE("GetLayerKml", "[KmlService]")
{
try
{
+ Ptr<MgKmlService> m_svcKml = TestServiceFactory::CreateKmlService();
+ Ptr<MgResourceService> m_svcResource = TestServiceFactory::CreateResourceService();
+
//create the layer
Ptr<MgResourceIdentifier> ldfres = new MgResourceIdentifier(L"Library://UnitTests/Layers/Parcels.LayerDefinition");
Ptr<MgLayer> layer = new MgLayer(ldfres, m_svcResource);
@@ -340,7 +236,7 @@
Ptr<MgByteReader> reader = m_svcKml->GetLayerKml(layer, extents, width, height, dpi, drawOrder, agentUri, format);
STRING mimeType = reader->GetMimeType();
- CPPUNIT_ASSERT(mimeType.compare(MgMimeType::Kml) == 0);
+ REQUIRE(mimeType.compare(MgMimeType::Kml) == 0);
}
catch(MgConnectionFailedException* e)
{
@@ -356,13 +252,13 @@
//compare results against referenced content
//TODO: Find a way to make the comparison work on Windows AND Linux
- //CPPUNIT_ASSERT(CompareContent(reader, L"../UnitTestFiles/UT_GetLayerKMLResult.txt"));
+ //REQUIRE(CompareContent(reader, L"../UnitTestFiles/UT_GetLayerKMLResult.txt"));
}
catch(MgException* e)
{
- STRING message = e->GetDetails(TEST_LOCALE);
+ STRING message = e->GetDetails(TestServiceFactory::TEST_LOCALE);
SAFE_RELEASE(e);
- CPPUNIT_FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
+ FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
}
catch(...)
{
@@ -370,11 +266,13 @@
}
}
-
-void TestKmlService::TestCase_GetFeaturesKml()
+TEST_CASE("GetFeaturesKml", "[KmlService]")
{
try
{
+ Ptr<MgKmlService> m_svcKml = TestServiceFactory::CreateKmlService();
+ Ptr<MgResourceService> m_svcResource = TestServiceFactory::CreateResourceService();
+
//create the layer
Ptr<MgResourceIdentifier> ldfres = new MgResourceIdentifier(L"Library://UnitTests/Layers/Parcels.LayerDefinition");
Ptr<MgLayer> layer = new MgLayer(ldfres, m_svcResource);
@@ -394,7 +292,7 @@
Ptr<MgByteReader> reader = m_svcKml->GetFeaturesKml(layer, extents, width, height, dpi, drawOrder, agentUri, format);
STRING mimeType = reader->GetMimeType();
- CPPUNIT_ASSERT(mimeType.compare(MgMimeType::Kml) == 0);
+ REQUIRE(mimeType.compare(MgMimeType::Kml) == 0);
}
catch(MgConnectionFailedException* e)
{
@@ -411,101 +309,16 @@
//compare results against referenced content
//TODO: Find a way to make the comparison work on Windows AND Linux
//TODO: Find a way to allow tolerance in floating point value comparisons
- //CPPUNIT_ASSERT(CompareContent(reader, L"../UnitTestFiles/UT_GetFeaturesKMLResult.txt"));
+ //REQUIRE(CompareContent(reader, L"../UnitTestFiles/UT_GetFeaturesKMLResult.txt"));
}
catch(MgException* e)
{
- STRING message = e->GetDetails(TEST_LOCALE);
+ STRING message = e->GetDetails(TestServiceFactory::TEST_LOCALE);
SAFE_RELEASE(e);
- CPPUNIT_FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
+ FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
}
catch(...)
{
throw;
}
-}
-
-
-STRING TestKmlService::RemoveSessionIds(CREFSTRING content)
-{
- STRING newContent = content;
-
- STRING sessionId;
- Ptr<MgUserInformation> userInfo = MgUserInformation::GetCurrentUserInfo();
- if (userInfo != NULL)
- {
- sessionId = userInfo->GetMgSessionId();
- }
-
- if(!sessionId.empty())
- {
- STRING dummyId = L"SessionIDRemoved";
- STRING::size_type sessionIdLocation;
- do
- {
- sessionIdLocation = newContent.find(sessionId);
- if(sessionIdLocation != STRING::npos)
- {
- newContent.replace(sessionIdLocation, sessionId.length(), dummyId);
- }
- }
- while(sessionIdLocation != STRING::npos);
- }
- return newContent;
-}
-
-
-void TestKmlService::SaveToFile(CREFSTRING content, CREFSTRING filename)
-{
- FILE* file = ACE_OS::fopen(MG_WCHAR_TO_TCHAR(filename), ACE_TEXT("wt"));
- if (file != NULL)
- {
- fwprintf (file, content.c_str());
- fclose (file);
- }
-}
-
-
-STRING TestKmlService::LoadFromFile(CREFSTRING filename)
-{
- STRING content;
- FILE* file = ACE_OS::fopen(MG_WCHAR_TO_TCHAR(filename), ACE_TEXT("rt"));
- if (file != NULL)
- {
- wchar_t buffer[1024];
- while(fgetws(buffer, 1024, file) != NULL)
- {
- content.append(buffer);
- }
- fclose (file);
- }
- return content;
-}
-
-
-bool TestKmlService::CompareContent(MgByteReader* reader, CREFSTRING referenceFile)
-{
- bool match = false;
- reader->GetByteSource()->SetMimeType(L"text/xml");
- STRING content = reader->ToString();
- STRING thisContent = RemoveSessionIds(content);
-
- try
- {
- STRING referenceContent = LoadFromFile(referenceFile);
- match = (thisContent.compare(0, thisContent.length(), referenceContent) == 0);
- }
- catch(...)
- {
- match = false;
- }
-
- //if we didn't get a match, dump out the content we did get
- if(!match)
- {
- STRING errorFile = referenceFile + L".err";
- SaveToFile(thisContent, errorFile);
- }
-
- return match;
-}
+}
\ No newline at end of file
Deleted: sandbox/jng/catch2/Server/src/UnitTesting/TestKmlService.h
===================================================================
--- sandbox/jng/catch2/Server/src/UnitTesting/TestKmlService.h 2020-07-07 15:57:41 UTC (rev 9656)
+++ sandbox/jng/catch2/Server/src/UnitTesting/TestKmlService.h 2020-07-08 11:10:16 UTC (rev 9657)
@@ -1,62 +0,0 @@
-//
-// Copyright (C) 2007-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 TestKmlService_H_
-#define TestKmlService_H_
-
-#include <cppunit/extensions/HelperMacros.h>
-
-class TestKmlService : public CppUnit::TestFixture
-{
- CPPUNIT_TEST_SUITE(TestKmlService);
- CPPUNIT_TEST(TestStart); // This must be the very first unit test
-
- CPPUNIT_TEST(TestCase_GetMapKml);
- CPPUNIT_TEST(TestCase_GetMapKmz);
- CPPUNIT_TEST(TestCase_GetLayerKml);
- CPPUNIT_TEST(TestCase_GetFeaturesKml);
-
- CPPUNIT_TEST(TestEnd); // This must be the very last unit test
- CPPUNIT_TEST_SUITE_END();
-
-public:
- TestKmlService();
- ~TestKmlService();
-
- void setUp();
- void tearDown();
- void TestStart();
- void TestEnd();
-
- void TestCase_GetMapKml();
- void TestCase_GetMapKmz();
- void TestCase_GetLayerKml();
- void TestCase_GetFeaturesKml();
-
-private:
- void PublishTheResources();
- STRING RemoveSessionIds(CREFSTRING content);
- void SaveToFile(CREFSTRING content, CREFSTRING filename);
- STRING LoadFromFile(CREFSTRING filename);
- bool CompareContent(MgByteReader* reader, CREFSTRING referenceFile);
-
- Ptr<MgSiteConnection> m_siteConnection;
- Ptr<MgResourceService> m_svcResource;
- Ptr<MgKmlService> m_svcKml;
-};
-
-#endif // TestKmlService_H_
Modified: sandbox/jng/catch2/Server/src/UnitTesting/TestLogManager.cpp
===================================================================
--- sandbox/jng/catch2/Server/src/UnitTesting/TestLogManager.cpp 2020-07-07 15:57:41 UTC (rev 9656)
+++ sandbox/jng/catch2/Server/src/UnitTesting/TestLogManager.cpp 2020-07-08 11:10:16 UTC (rev 9657)
@@ -16,13 +16,14 @@
//
#include "MapGuideCommon.h"
-#include "TestLogManager.h"
-#include "CppUnitExtensions.h"
+#include "CatchHelperMacros.h"
#include "LogManager.h"
#include "TestLogManagerThread.h"
#include "FoundationDefs.h"
-CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(TestLogManager, "TestLogManager");
+#include "TestServiceFactory.h"
+#include "catch.hpp"
+
const wchar_t TestName[] = L"TestName.log";
const wchar_t TestName2[] = L"TestName2.log";
const wchar_t NewTestName[] = L"SuperCoolNewTestName.log";
@@ -50,26 +51,8 @@
const STRING LastEntry = L"<2005-03-08T00:57:08> Entry 5\n";
#endif
-void TestLogManager::setUp()
+static bool CreateFile(STRING filename, STRING contents)
{
-}
-
-void TestLogManager::tearDown()
-{
-}
-
-void TestLogManager::TestStart()
-{
- ACE_DEBUG((LM_INFO, ACE_TEXT("\nRunning Log Manager tests.\n")));
-}
-
-void TestLogManager::TestEnd()
-{
- ACE_DEBUG((LM_INFO, ACE_TEXT("\nLog Manager tests completed.\n\n")));
-}
-
-bool TestLogManager::CreateFile(STRING filename, STRING contents)
-{
FILE* file = NULL;
file = ::fopen(MG_WCHAR_TO_CHAR(filename), "wb");
@@ -91,13 +74,13 @@
/// This test case checks to see if there is a valid MgLogManager and that
/// there is only 1 MgLogManager.
///----------------------------------------------------------------------------
-void TestLogManager::TestCase_ValidLogManager()
+TEST_CASE("Valid Log Manager", "[LogManager]")
{
MgLogManager* pMgLogManager = MgLogManager::GetInstance();
- CPPUNIT_ASSERT(pMgLogManager != NULL);
+ REQUIRE(pMgLogManager != nullptr);
MgLogManager* pMgLogManager2 = MgLogManager::GetInstance();
- CPPUNIT_ASSERT(pMgLogManager == pMgLogManager2);
+ REQUIRE(pMgLogManager == pMgLogManager2);
}
///----------------------------------------------------------------------------
@@ -105,12 +88,12 @@
///
/// This test case checks the logs path.
///----------------------------------------------------------------------------
-void TestLogManager::TestCase_GetLogsPath()
+TEST_CASE("GetLogsPath", "[LogManager]")
{
MgLogManager* pMgLogManager = MgLogManager::GetInstance();
CREFSTRING path = pMgLogManager->GetLogsPath();
- CPPUNIT_ASSERT(path.length() > 0);
+ REQUIRE(path.length() > 0);
}
///----------------------------------------------------------------------------
@@ -119,7 +102,7 @@
/// This test case hits the log manager with multiple threads to ensure that
/// it encounters no deadlocking.
///----------------------------------------------------------------------------
-void TestLogManager::TestCase_TestForDeadLock()
+TEST_CASE("Testing for dead lock", "[LogManager]")
{
try
{
@@ -131,7 +114,7 @@
{
STRING message = e->GetDetails(TEST_LOCALE);
SAFE_RELEASE(e);
- CPPUNIT_FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
+ FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
}
catch (...)
{
@@ -145,7 +128,7 @@
/// This test case enumerates the log files that are currently located in the
/// logs directory
///----------------------------------------------------------------------------
-void TestLogManager::TestCase_EnumerateLogs()
+TEST_CASE("EnumerateLogs", "[LogManager]")
{
try
{
@@ -166,16 +149,16 @@
Ptr<MgStringProperty> testName2Prop = new MgStringProperty(L"LogNameProperty", TestName2);
Ptr<MgStringProperty> junkName2Prop = new MgStringProperty(L"LogNameProperty", JunkName2);
- CPPUNIT_ASSERT(logs->Contains(junkNameProp));
- CPPUNIT_ASSERT(logs->Contains(testNameProp));
- CPPUNIT_ASSERT(logs->Contains(junkName2Prop));
- CPPUNIT_ASSERT(logs->Contains(testName2Prop));
+ REQUIRE(logs->Contains(junkNameProp));
+ REQUIRE(logs->Contains(testNameProp));
+ REQUIRE(logs->Contains(junkName2Prop));
+ REQUIRE(logs->Contains(testName2Prop));
}
catch (MgException* e)
{
STRING message = e->GetDetails(TEST_LOCALE);
SAFE_RELEASE(e);
- CPPUNIT_FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
+ FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
}
catch (...)
{
@@ -189,7 +172,7 @@
/// This test case deletes log files that were created during the running
/// of the log manager tests
///----------------------------------------------------------------------------
-void TestLogManager::TestCase_DeleteLog()
+TEST_CASE("DeleteLog", "[LogManager]")
{
try
{
@@ -203,17 +186,17 @@
Ptr<MgPropertyCollection> logs = pMgLogManager->EnumerateLogs();
- CPPUNIT_ASSERT(!logs->Contains(TestName));
- CPPUNIT_ASSERT(!logs->Contains(NewTestName));
- CPPUNIT_ASSERT(!logs->Contains(JunkName));
- CPPUNIT_ASSERT(!logs->Contains(TestName2));
- CPPUNIT_ASSERT(!logs->Contains(JunkName2));
+ REQUIRE(!logs->Contains(TestName));
+ REQUIRE(!logs->Contains(NewTestName));
+ REQUIRE(!logs->Contains(JunkName));
+ REQUIRE(!logs->Contains(TestName2));
+ REQUIRE(!logs->Contains(JunkName2));
}
catch (MgException* e)
{
STRING message = e->GetDetails(TEST_LOCALE);
SAFE_RELEASE(e);
- CPPUNIT_FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
+ FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
}
catch (...)
{
@@ -226,7 +209,7 @@
/// This test case creates a file in the logs folder and then uses the api
/// to rename it.
///----------------------------------------------------------------------------
-void TestLogManager::TestCase_RenameLog()
+TEST_CASE("RenameLog", "[LogManager]")
{
try
{
@@ -242,14 +225,14 @@
Ptr<MgPropertyCollection> logs = pMgLogManager->EnumerateLogs();
Ptr<MgStringProperty> newTestNameProp = new MgStringProperty(L"LogNameProperty", NewTestName);
- CPPUNIT_ASSERT(logs->Contains(newTestNameProp));
+ REQUIRE(logs->Contains(newTestNameProp));
- CPPUNIT_ASSERT_THROW_MG(pMgLogManager->RenameLog(L"", NewTestName), MgInvalidArgumentException*);
- CPPUNIT_ASSERT_THROW_MG(pMgLogManager->RenameLog(NewTestName, L""), MgInvalidArgumentException*);
- CPPUNIT_ASSERT_THROW_MG(pMgLogManager->RenameLog(TestName, TestName), MgDuplicateFileException*);
- CPPUNIT_ASSERT_THROW_MG(pMgLogManager->RenameLog(L"DoesNotExist.log", L"NewDoesNotExist.log"), MgFileNotFoundException*);
+ REQUIRE_THROWS_MG(pMgLogManager->RenameLog(L"", NewTestName), MgInvalidArgumentException*);
+ REQUIRE_THROWS_MG(pMgLogManager->RenameLog(NewTestName, L""), MgInvalidArgumentException*);
+ REQUIRE_THROWS_MG(pMgLogManager->RenameLog(TestName, TestName), MgDuplicateFileException*);
+ REQUIRE_THROWS_MG(pMgLogManager->RenameLog(L"DoesNotExist.log", L"NewDoesNotExist.log"), MgFileNotFoundException*);
#ifdef _WIN32
- CPPUNIT_ASSERT_THROW_MG(pMgLogManager->RenameLog(NewTestName, L"?"), MgInvalidArgumentException*);
+ REQUIRE_THROWS_MG(pMgLogManager->RenameLog(NewTestName, L"?"), MgInvalidArgumentException*);
#endif
}
catch (MgException* e)
@@ -256,7 +239,7 @@
{
STRING message = e->GetDetails(TEST_LOCALE);
SAFE_RELEASE(e);
- CPPUNIT_FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
+ FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
}
catch (...)
{
@@ -269,7 +252,7 @@
///
/// This test case tries to change the log info.
///----------------------------------------------------------------------------
-void TestLogManager::TestCase_SetAccessLogInfo()
+TEST_CASE("SetAccessLogInfo", "[LogManager]")
{
try
{
@@ -289,15 +272,15 @@
// Restore original info
pMgLogManager->SetAccessLogInfo(bOriginalEnabled, originalName, originalParams);
- CPPUNIT_ASSERT(bEnabled == false);
- CPPUNIT_ASSERT(wcscmp(name.c_str(), TestName) == 0);
- CPPUNIT_ASSERT(wcscmp(params.c_str(), TestParameters) == 0);
+ REQUIRE(bEnabled == false);
+ REQUIRE(wcscmp(name.c_str(), TestName) == 0);
+ REQUIRE(wcscmp(params.c_str(), TestParameters) == 0);
}
catch (MgException* e)
{
STRING message = e->GetDetails(TEST_LOCALE);
SAFE_RELEASE(e);
- CPPUNIT_FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
+ FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
}
catch (...)
{
@@ -310,19 +293,19 @@
///
/// This test case tries to clear the log.
///----------------------------------------------------------------------------
-void TestLogManager::TestCase_ClearAccessLog()
+TEST_CASE("ClearAccessLog", "[LogManager]")
{
try
{
MgLogManager* pMgLogManager = MgLogManager::GetInstance();
bool bResult = pMgLogManager->ClearAccessLog();
- CPPUNIT_ASSERT(bResult);
+ REQUIRE(bResult);
}
catch (MgException* e)
{
STRING message = e->GetDetails(TEST_LOCALE);
SAFE_RELEASE(e);
- CPPUNIT_FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
+ FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
}
catch (...)
{
@@ -335,7 +318,7 @@
///
/// This test case tries to get the contents of the log.
///----------------------------------------------------------------------------
-void TestLogManager::TestCase_GetAccessLog()
+TEST_CASE("GetAccessLog", "[LogManager]")
{
MgLogManager* pMgLogManager = MgLogManager::GetInstance();
STRING path = pMgLogManager->GetLogsPath();
@@ -363,7 +346,7 @@
pMgLogManager->SetAccessLogFileName(originalName);
STRING message = e->GetDetails(TEST_LOCALE);
SAFE_RELEASE(e);
- CPPUNIT_FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
+ FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
}
catch (...)
{
@@ -371,8 +354,8 @@
throw;
}
- CPPUNIT_ASSERT(logContents == contents);
- CPPUNIT_ASSERT(lastLogEntry == LastEntry);
+ REQUIRE(logContents == contents);
+ REQUIRE(lastLogEntry == LastEntry);
}
///----------------------------------------------------------------------------
@@ -380,7 +363,7 @@
///
/// This test case tries to get the contents of the log between two dates.
///----------------------------------------------------------------------------
-void TestLogManager::TestCase_GetAccessLogByDate()
+TEST_CASE("GetAccessLogByDate", "[LogManager]")
{
MgLogManager* pMgLogManager = MgLogManager::GetInstance();
STRING path = pMgLogManager->GetLogsPath();
@@ -405,7 +388,7 @@
toDate = new MgDateTime(2005, 3, 7, 16, 54, 19, 0);
byteReader = pMgLogManager->GetAccessLog(fromDate, toDate);
logContents = MgUtil::MultiByteToWideChar(MgUtil::GetTextFromReader(byteReader));
- CPPUNIT_ASSERT(logContents == (Entry1 + Entry2 + Entry3));
+ REQUIRE(logContents == (Entry1 + Entry2 + Entry3));
// from & to date are the same and at exact time an entry was made
fromDate = new MgDateTime(2005, 3, 7, 16, 51, 13, 0);
@@ -412,7 +395,7 @@
toDate = new MgDateTime(2005, 3, 7, 16, 51, 13, 0);
byteReader = pMgLogManager->GetAccessLog(fromDate, toDate);
logContents = MgUtil::MultiByteToWideChar(MgUtil::GetTextFromReader(byteReader));
- CPPUNIT_ASSERT(logContents == Entry1);
+ REQUIRE(logContents == Entry1);
// from & to date are the same and not at exact time an entry was made
fromDate = new MgDateTime(2005, 3, 7, 16, 52, 0, 0);
@@ -419,7 +402,7 @@
toDate = new MgDateTime(2005, 3, 7, 16, 52, 0, 0);
byteReader = pMgLogManager->GetAccessLog(fromDate, toDate);
logContents = MgUtil::MultiByteToWideChar(MgUtil::GetTextFromReader(byteReader));
- CPPUNIT_ASSERT(logContents.length() == 0);
+ REQUIRE(logContents.length() == 0);
// from & to dates are at not at exact times an entry was made
fromDate = new MgDateTime(2005, 3, 7, 16, 52, 0, 0);
@@ -426,7 +409,7 @@
toDate = new MgDateTime(2005, 3, 7, 16, 56, 0, 0);
byteReader = pMgLogManager->GetAccessLog(fromDate, toDate);
logContents = MgUtil::MultiByteToWideChar(MgUtil::GetTextFromReader(byteReader));
- CPPUNIT_ASSERT(logContents == (Entry2 + Entry3 + Entry4));
+ REQUIRE(logContents == (Entry2 + Entry3 + Entry4));
// spans two different files
fromDate = new MgDateTime(2005, 3, 7, 16, 52, 0, 0);
@@ -433,7 +416,7 @@
toDate = new MgDateTime(2005, 3, 8, 1, 0, 0, 0);
byteReader = pMgLogManager->GetAccessLog(fromDate, toDate);
logContents = MgUtil::MultiByteToWideChar(MgUtil::GetTextFromReader(byteReader));
- CPPUNIT_ASSERT(logContents == (Entry2 + Entry3 + Entry4 + LastEntry));
+ REQUIRE(logContents == (Entry2 + Entry3 + Entry4 + LastEntry));
// spans two different files, the first of which doesn't exist
fromDate = new MgDateTime(2005, 3, 6, 23, 59, 59, 0);
@@ -440,7 +423,7 @@
toDate = new MgDateTime(2005, 3, 7, 16, 52, 0, 0);
byteReader = pMgLogManager->GetAccessLog(fromDate, toDate);
logContents = MgUtil::MultiByteToWideChar(MgUtil::GetTextFromReader(byteReader));
- CPPUNIT_ASSERT(logContents == Entry1);
+ REQUIRE(logContents == Entry1);
// spans two different files, the second of which doesn't exist
fromDate = new MgDateTime(2005, 3, 8, 0, 0, 0, 0);
@@ -447,7 +430,7 @@
toDate = new MgDateTime(2005, 3, 9, 0, 0, 0, 0);
byteReader = pMgLogManager->GetAccessLog(fromDate, toDate);
logContents = MgUtil::MultiByteToWideChar(MgUtil::GetTextFromReader(byteReader));
- CPPUNIT_ASSERT(logContents == LastEntry);
+ REQUIRE(logContents == LastEntry);
// from date is after the latest entry in the log files
fromDate = new MgDateTime(2006, 1, 1, 1, 0, 0, 0);
@@ -454,15 +437,15 @@
toDate = new MgDateTime(2006, 1, 1, 1, 0, 0, 0);
byteReader = pMgLogManager->GetAccessLog(fromDate, toDate);
logContents = MgUtil::MultiByteToWideChar(MgUtil::GetTextFromReader(byteReader));
- CPPUNIT_ASSERT(logContents.length() == 0);
+ REQUIRE(logContents.length() == 0);
// Use a null value for the date
- CPPUNIT_ASSERT_THROW_MG(pMgLogManager->GetAccessLog(NULL, toDate), MgNullArgumentException*);
+ REQUIRE_THROWS_MG(pMgLogManager->GetAccessLog(NULL, toDate), MgNullArgumentException*);
// Use dates more than 24 hours apart
fromDate = new MgDateTime(2005, 2, 18, 14, 0, 0, 0);
toDate = new MgDateTime(2005, 2, 19, 18, 0, 0, 0);
- CPPUNIT_ASSERT_THROW_MG(pMgLogManager->GetAccessLog(fromDate, toDate), MgInvalidArgumentException*);
+ REQUIRE_THROWS_MG(pMgLogManager->GetAccessLog(fromDate, toDate), MgInvalidArgumentException*);
// Search a log file with an invalid log entry as the first entry
CreateFile(path + JunkName, L"asdfasdfasdf");
@@ -469,7 +452,7 @@
pMgLogManager->SetAccessLogFileName(JunkName);
fromDate = new MgDateTime(2005, 3, 8, 0, 0, 0, 0);
toDate = new MgDateTime(2005, 3, 9, 0, 0, 0, 0);
- CPPUNIT_ASSERT_THROW_MG(pMgLogManager->GetAccessLog(fromDate, toDate), MgInvalidLogEntryException*);
+ REQUIRE_THROWS_MG(pMgLogManager->GetAccessLog(fromDate, toDate), MgInvalidLogEntryException*);
pMgLogManager->SetAccessLogFileName(originalName);
}
@@ -478,7 +461,7 @@
pMgLogManager->SetAccessLogFileName(originalName);
STRING message = e->GetDetails(TEST_LOCALE);
SAFE_RELEASE(e);
- CPPUNIT_FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
+ FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
}
catch (...)
{
@@ -493,10 +476,10 @@
/// This test case tries to get the contents of the log using an invalid
/// argument. An exception should be thrown.
///----------------------------------------------------------------------------
-void TestLogManager::TestCase_GetAccessLogInvalid()
+TEST_CASE("GetAccessLogInvalid", "[LogManager]")
{
MgLogManager* pMgLogManager = MgLogManager::GetInstance();
- CPPUNIT_ASSERT_THROW_MG(pMgLogManager->GetAccessLog(-1), MgArgumentOutOfRangeException*);
+ REQUIRE_THROWS_MG(pMgLogManager->GetAccessLog(-1), MgArgumentOutOfRangeException*);
}
///----------------------------------------------------------------------------
@@ -504,7 +487,7 @@
///
/// This test case tries to change the log info.
///----------------------------------------------------------------------------
-void TestLogManager::TestCase_SetAdminLogInfo()
+TEST_CASE("SetAdminLogInfo", "[LogManager]")
{
try
{
@@ -524,15 +507,15 @@
// Restore original info
pMgLogManager->SetAdminLogInfo(bOriginalEnabled, originalName, originalParams);
- CPPUNIT_ASSERT(bEnabled == false);
- CPPUNIT_ASSERT(wcscmp(name.c_str(), TestName) == 0);
- CPPUNIT_ASSERT(wcscmp(params.c_str(), TestParameters) == 0);
+ REQUIRE(bEnabled == false);
+ REQUIRE(wcscmp(name.c_str(), TestName) == 0);
+ REQUIRE(wcscmp(params.c_str(), TestParameters) == 0);
}
catch (MgException* e)
{
STRING message = e->GetDetails(TEST_LOCALE);
SAFE_RELEASE(e);
- CPPUNIT_FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
+ FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
}
catch (...)
{
@@ -545,19 +528,19 @@
///
/// This test case tries to clear the log.
///----------------------------------------------------------------------------
-void TestLogManager::TestCase_ClearAdminLog()
+TEST_CASE("ClearAdminLog", "[LogManager]")
{
try
{
MgLogManager* pMgLogManager = MgLogManager::GetInstance();
bool bResult = pMgLogManager->ClearAdminLog();
- CPPUNIT_ASSERT(bResult);
+ REQUIRE(bResult);
}
catch (MgException* e)
{
STRING message = e->GetDetails(TEST_LOCALE);
SAFE_RELEASE(e);
- CPPUNIT_FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
+ FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
}
catch (...)
{
@@ -570,7 +553,7 @@
///
/// This test case tries to get the contents of the log.
///----------------------------------------------------------------------------
-void TestLogManager::TestCase_GetAdminLog()
+TEST_CASE("GetAdminLog", "[LogManager]")
{
MgLogManager* pMgLogManager = MgLogManager::GetInstance();
STRING path = pMgLogManager->GetLogsPath();
@@ -596,7 +579,7 @@
pMgLogManager->SetAdminLogFileName(originalName);
STRING message = e->GetDetails(TEST_LOCALE);
SAFE_RELEASE(e);
- CPPUNIT_FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
+ FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
}
catch (...)
{
@@ -604,8 +587,8 @@
throw;
}
- CPPUNIT_ASSERT(logContents == contents);
- CPPUNIT_ASSERT(lastLogEntry == LastEntry);
+ REQUIRE(logContents == contents);
+ REQUIRE(lastLogEntry == LastEntry);
}
///----------------------------------------------------------------------------
@@ -613,7 +596,7 @@
///
/// This test case tries to get the contents of the log between two dates.
///----------------------------------------------------------------------------
-void TestLogManager::TestCase_GetAdminLogByDate()
+TEST_CASE("GetAdminLogByDate", "[LogManager]")
{
MgLogManager* pMgLogManager = MgLogManager::GetInstance();
STRING path = pMgLogManager->GetLogsPath();
@@ -638,7 +621,7 @@
toDate = new MgDateTime(2005, 3, 7, 16, 54, 19, 0);
byteReader = pMgLogManager->GetAdminLog(fromDate, toDate);
logContents = MgUtil::MultiByteToWideChar(MgUtil::GetTextFromReader(byteReader));
- CPPUNIT_ASSERT(logContents == (Entry1 + Entry2 + Entry3));
+ REQUIRE(logContents == (Entry1 + Entry2 + Entry3));
// from & to date are the same and at exact time an entry was made
fromDate = new MgDateTime(2005, 3, 7, 16, 51, 13, 0);
@@ -645,7 +628,7 @@
toDate = new MgDateTime(2005, 3, 7, 16, 51, 13, 0);
byteReader = pMgLogManager->GetAdminLog(fromDate, toDate);
logContents = MgUtil::MultiByteToWideChar(MgUtil::GetTextFromReader(byteReader));
- CPPUNIT_ASSERT(logContents == Entry1);
+ REQUIRE(logContents == Entry1);
// from & to date are the same and not at exact time an entry was made
fromDate = new MgDateTime(2005, 3, 7, 16, 52, 0, 0);
@@ -652,7 +635,7 @@
toDate = new MgDateTime(2005, 3, 7, 16, 52, 0, 0);
byteReader = pMgLogManager->GetAdminLog(fromDate, toDate);
logContents = MgUtil::MultiByteToWideChar(MgUtil::GetTextFromReader(byteReader));
- CPPUNIT_ASSERT(logContents.length() == 0);
+ REQUIRE(logContents.length() == 0);
// from & to dates are at not at exact times an entry was made
fromDate = new MgDateTime(2005, 3, 7, 16, 52, 0, 0);
@@ -659,7 +642,7 @@
toDate = new MgDateTime(2005, 3, 7, 16, 56, 0, 0);
byteReader = pMgLogManager->GetAdminLog(fromDate, toDate);
logContents = MgUtil::MultiByteToWideChar(MgUtil::GetTextFromReader(byteReader));
- CPPUNIT_ASSERT(logContents == (Entry2 + Entry3 + Entry4));
+ REQUIRE(logContents == (Entry2 + Entry3 + Entry4));
// spans two different files, the second of which doesn't exist
fromDate = new MgDateTime(2005, 3, 8, 0, 0, 0, 0);
@@ -666,7 +649,7 @@
toDate = new MgDateTime(2005, 3, 9, 0, 0, 0, 0);
byteReader = pMgLogManager->GetAdminLog(fromDate, toDate);
logContents = MgUtil::MultiByteToWideChar(MgUtil::GetTextFromReader(byteReader));
- CPPUNIT_ASSERT(logContents == LastEntry);
+ REQUIRE(logContents == LastEntry);
// from date is after the latest entry in the log files
fromDate = new MgDateTime(2006, 1, 1, 1, 0, 0, 0);
@@ -673,15 +656,15 @@
toDate = new MgDateTime(2006, 1, 1, 1, 0, 0, 0);
byteReader = pMgLogManager->GetAdminLog(fromDate, toDate);
logContents = MgUtil::MultiByteToWideChar(MgUtil::GetTextFromReader(byteReader));
- CPPUNIT_ASSERT(logContents.length() == 0);
+ REQUIRE(logContents.length() == 0);
// Use a null value for the date
- CPPUNIT_ASSERT_THROW_MG(pMgLogManager->GetAdminLog(NULL, toDate), MgNullArgumentException*);
+ REQUIRE_THROWS_MG(pMgLogManager->GetAdminLog(NULL, toDate), MgNullArgumentException*);
// Use dates more than 24 hours apart
fromDate = new MgDateTime(2005, 2, 18, 14, 0, 0, 0);
toDate = new MgDateTime(2005, 2, 19, 18, 0, 0, 0);
- CPPUNIT_ASSERT_THROW_MG(pMgLogManager->GetAdminLog(fromDate, toDate), MgInvalidArgumentException*);
+ REQUIRE_THROWS_MG(pMgLogManager->GetAdminLog(fromDate, toDate), MgInvalidArgumentException*);
pMgLogManager->SetAdminLogFileName(originalName);
}
@@ -690,7 +673,7 @@
pMgLogManager->SetAdminLogFileName(originalName);
STRING message = e->GetDetails(TEST_LOCALE);
SAFE_RELEASE(e);
- CPPUNIT_FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
+ FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
}
catch (...)
{
@@ -705,10 +688,10 @@
/// This test case tries to get the contents of the log using an invalid
/// argument. An exception should be thrown.
///----------------------------------------------------------------------------
-void TestLogManager::TestCase_GetAdminLogInvalid()
+TEST_CASE("GetAdminLogInvalid", "[LogManager]")
{
MgLogManager* pMgLogManager = MgLogManager::GetInstance();
- CPPUNIT_ASSERT_THROW_MG(pMgLogManager->GetAdminLog(-1), MgArgumentOutOfRangeException*);
+ REQUIRE_THROWS_MG(pMgLogManager->GetAdminLog(-1), MgArgumentOutOfRangeException*);
}
///----------------------------------------------------------------------------
@@ -716,7 +699,7 @@
///
/// This test case tries to change the log info.
///----------------------------------------------------------------------------
-void TestLogManager::TestCase_SetAuthenticationLogInfo()
+TEST_CASE("SetAuthenticationLogInfo", "[LogManager]")
{
try
{
@@ -736,15 +719,15 @@
// Restore original info
pMgLogManager->SetAuthenticationLogInfo(bOriginalEnabled, originalName, originalParams);
- CPPUNIT_ASSERT(bEnabled == false);
- CPPUNIT_ASSERT(wcscmp(name.c_str(), TestName) == 0);
- CPPUNIT_ASSERT(wcscmp(params.c_str(), TestParameters) == 0);
+ REQUIRE(bEnabled == false);
+ REQUIRE(wcscmp(name.c_str(), TestName) == 0);
+ REQUIRE(wcscmp(params.c_str(), TestParameters) == 0);
}
catch (MgException* e)
{
STRING message = e->GetDetails(TEST_LOCALE);
SAFE_RELEASE(e);
- CPPUNIT_FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
+ FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
}
catch (...)
{
@@ -757,19 +740,19 @@
///
/// This test case tries to clear the log.
///----------------------------------------------------------------------------
-void TestLogManager::TestCase_ClearAuthenticationLog()
+TEST_CASE("ClearAuthenticationLog", "[LogManager]")
{
try
{
MgLogManager* pMgLogManager = MgLogManager::GetInstance();
bool bResult = pMgLogManager->ClearAuthenticationLog();
- CPPUNIT_ASSERT(bResult);
+ REQUIRE(bResult);
}
catch (MgException* e)
{
STRING message = e->GetDetails(TEST_LOCALE);
SAFE_RELEASE(e);
- CPPUNIT_FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
+ FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
}
catch (...)
{
@@ -782,7 +765,7 @@
///
/// This test case tries to get the contents of the log.
///----------------------------------------------------------------------------
-void TestLogManager::TestCase_GetAuthenticationLog()
+TEST_CASE("GetAuthenticationLog", "[LogManager]")
{
MgLogManager* pMgLogManager = MgLogManager::GetInstance();
STRING path = pMgLogManager->GetLogsPath();
@@ -808,7 +791,7 @@
pMgLogManager->SetAuthenticationLogFileName(originalName);
STRING message = e->GetDetails(TEST_LOCALE);
SAFE_RELEASE(e);
- CPPUNIT_FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
+ FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
}
catch (...)
{
@@ -816,8 +799,8 @@
throw;
}
- CPPUNIT_ASSERT(logContents == contents);
- CPPUNIT_ASSERT(lastLogEntry == LastEntry);
+ REQUIRE(logContents == contents);
+ REQUIRE(lastLogEntry == LastEntry);
}
///----------------------------------------------------------------------------
@@ -825,7 +808,7 @@
///
/// This test case tries to get the contents of the log between two dates.
///----------------------------------------------------------------------------
-void TestLogManager::TestCase_GetAuthenticationLogByDate()
+TEST_CASE("GetAuthenticationLogByDate", "[LogManager]")
{
MgLogManager* pMgLogManager = MgLogManager::GetInstance();
STRING path = pMgLogManager->GetLogsPath();
@@ -850,7 +833,7 @@
toDate = new MgDateTime(2005, 3, 7, 16, 54, 19, 0);
byteReader = pMgLogManager->GetAuthenticationLog(fromDate, toDate);
logContents = MgUtil::MultiByteToWideChar(MgUtil::GetTextFromReader(byteReader));
- CPPUNIT_ASSERT(logContents == (Entry1 + Entry2 + Entry3));
+ REQUIRE(logContents == (Entry1 + Entry2 + Entry3));
// from & to dates are at not at exact times an entry was made
fromDate = new MgDateTime(2005, 3, 7, 16, 52, 0, 0);
@@ -857,7 +840,7 @@
toDate = new MgDateTime(2005, 3, 7, 16, 56, 0, 0);
byteReader = pMgLogManager->GetAuthenticationLog(fromDate, toDate);
logContents = MgUtil::MultiByteToWideChar(MgUtil::GetTextFromReader(byteReader));
- CPPUNIT_ASSERT(logContents == (Entry2 + Entry3 + Entry4));
+ REQUIRE(logContents == (Entry2 + Entry3 + Entry4));
// spans two different files
fromDate = new MgDateTime(2005, 3, 7, 16, 52, 0, 0);
@@ -864,7 +847,7 @@
toDate = new MgDateTime(2005, 3, 8, 1, 0, 0, 0);
byteReader = pMgLogManager->GetAuthenticationLog(fromDate, toDate);
logContents = MgUtil::MultiByteToWideChar(MgUtil::GetTextFromReader(byteReader));
- CPPUNIT_ASSERT(logContents == (Entry2 + Entry3 + Entry4 + LastEntry));
+ REQUIRE(logContents == (Entry2 + Entry3 + Entry4 + LastEntry));
// spans two different files, the first of which doesn't exist
fromDate = new MgDateTime(2005, 3, 6, 23, 59, 59, 0);
@@ -871,7 +854,7 @@
toDate = new MgDateTime(2005, 3, 7, 16, 52, 0, 0);
byteReader = pMgLogManager->GetAuthenticationLog(fromDate, toDate);
logContents = MgUtil::MultiByteToWideChar(MgUtil::GetTextFromReader(byteReader));
- CPPUNIT_ASSERT(logContents == Entry1);
+ REQUIRE(logContents == Entry1);
// spans two different files, the second of which doesn't exist
fromDate = new MgDateTime(2005, 3, 8, 0, 0, 0, 0);
@@ -878,7 +861,7 @@
toDate = new MgDateTime(2005, 3, 9, 0, 0, 0, 0);
byteReader = pMgLogManager->GetAuthenticationLog(fromDate, toDate);
logContents = MgUtil::MultiByteToWideChar(MgUtil::GetTextFromReader(byteReader));
- CPPUNIT_ASSERT(logContents == LastEntry);
+ REQUIRE(logContents == LastEntry);
// from date is after the latest entry in the log files
fromDate = new MgDateTime(2006, 1, 1, 1, 0, 0, 0);
@@ -885,15 +868,15 @@
toDate = new MgDateTime(2006, 1, 1, 1, 0, 0, 0);
byteReader = pMgLogManager->GetAuthenticationLog(fromDate, toDate);
logContents = MgUtil::MultiByteToWideChar(MgUtil::GetTextFromReader(byteReader));
- CPPUNIT_ASSERT(logContents.length() == 0);
+ REQUIRE(logContents.length() == 0);
// Use a null value for the date
- CPPUNIT_ASSERT_THROW_MG(pMgLogManager->GetAuthenticationLog(NULL, toDate), MgNullArgumentException*);
+ REQUIRE_THROWS_MG(pMgLogManager->GetAuthenticationLog(NULL, toDate), MgNullArgumentException*);
// Use dates more than 24 hours apart
fromDate = new MgDateTime(2005, 2, 18, 14, 0, 0, 0);
toDate = new MgDateTime(2005, 2, 19, 18, 0, 0, 0);
- CPPUNIT_ASSERT_THROW_MG(pMgLogManager->GetAuthenticationLog(fromDate, toDate), MgInvalidArgumentException*);
+ REQUIRE_THROWS_MG(pMgLogManager->GetAuthenticationLog(fromDate, toDate), MgInvalidArgumentException*);
pMgLogManager->SetAuthenticationLogFileName(originalName);
}
@@ -902,7 +885,7 @@
pMgLogManager->SetAuthenticationLogFileName(originalName);
STRING message = e->GetDetails(TEST_LOCALE);
SAFE_RELEASE(e);
- CPPUNIT_FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
+ FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
}
catch (...)
{
@@ -917,10 +900,10 @@
/// This test case tries to get the contents of the log using an invalid
/// argument. An exception should be thrown.
///----------------------------------------------------------------------------
-void TestLogManager::TestCase_GetAuthenticationLogInvalid()
+TEST_CASE("GetAuthenticationLogInvalid", "[LogManager]")
{
MgLogManager* pMgLogManager = MgLogManager::GetInstance();
- CPPUNIT_ASSERT_THROW_MG(pMgLogManager->GetAuthenticationLog(-1), MgArgumentOutOfRangeException*);
+ REQUIRE_THROWS_MG(pMgLogManager->GetAuthenticationLog(-1), MgArgumentOutOfRangeException*);
}
///----------------------------------------------------------------------------
@@ -928,7 +911,7 @@
///
/// This test case tries to change the log info.
///----------------------------------------------------------------------------
-void TestLogManager::TestCase_SetErrorLogInfo()
+TEST_CASE("SetErrorLogInfo", "[LogManager]")
{
try
{
@@ -948,15 +931,15 @@
// Restore original info
pMgLogManager->SetErrorLogInfo(bOriginalEnabled, originalName, originalParams);
- CPPUNIT_ASSERT(bEnabled == false);
- CPPUNIT_ASSERT(wcscmp(name.c_str(), TestName) == 0);
- CPPUNIT_ASSERT(wcscmp(params.c_str(), TestParameters) == 0);
+ REQUIRE(bEnabled == false);
+ REQUIRE(wcscmp(name.c_str(), TestName) == 0);
+ REQUIRE(wcscmp(params.c_str(), TestParameters) == 0);
}
catch (MgException* e)
{
STRING message = e->GetDetails(TEST_LOCALE);
SAFE_RELEASE(e);
- CPPUNIT_FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
+ FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
}
catch (...)
{
@@ -969,19 +952,19 @@
///
/// This test case tries to clear the log.
///----------------------------------------------------------------------------
-void TestLogManager::TestCase_ClearErrorLog()
+TEST_CASE("ClearErrorLog", "[LogManager]")
{
try
{
MgLogManager* pMgLogManager = MgLogManager::GetInstance();
bool bResult = pMgLogManager->ClearErrorLog();
- CPPUNIT_ASSERT(bResult);
+ REQUIRE(bResult);
}
catch (MgException* e)
{
STRING message = e->GetDetails(TEST_LOCALE);
SAFE_RELEASE(e);
- CPPUNIT_FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
+ FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
}
catch (...)
{
@@ -994,7 +977,7 @@
///
/// This test case tries to get the contents of the log.
///----------------------------------------------------------------------------
-void TestLogManager::TestCase_GetErrorLog()
+TEST_CASE("GetErrorLog", "[LogManager]")
{
MgLogManager* pMgLogManager = MgLogManager::GetInstance();
STRING path = pMgLogManager->GetLogsPath();
@@ -1020,7 +1003,7 @@
pMgLogManager->SetErrorLogFileName(originalName);
STRING message = e->GetDetails(TEST_LOCALE);
SAFE_RELEASE(e);
- CPPUNIT_FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
+ FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
}
catch (...)
{
@@ -1028,8 +1011,8 @@
throw;
}
- CPPUNIT_ASSERT(logContents == contents);
- CPPUNIT_ASSERT(lastLogEntry == LastEntry);
+ REQUIRE(logContents == contents);
+ REQUIRE(lastLogEntry == LastEntry);
}
///----------------------------------------------------------------------------
@@ -1037,7 +1020,7 @@
///
/// This test case tries to get the contents of the log between two dates.
///----------------------------------------------------------------------------
-void TestLogManager::TestCase_GetErrorLogByDate()
+TEST_CASE("GetErrorLogByDate", "[LogManager]")
{
MgLogManager* pMgLogManager = MgLogManager::GetInstance();
STRING path = pMgLogManager->GetLogsPath();
@@ -1062,7 +1045,7 @@
toDate = new MgDateTime(2005, 3, 7, 16, 54, 19, 0);
byteReader = pMgLogManager->GetErrorLog(fromDate, toDate);
logContents = MgUtil::MultiByteToWideChar(MgUtil::GetTextFromReader(byteReader));
- CPPUNIT_ASSERT(logContents == (Entry1 + Entry2 + Entry3));
+ REQUIRE(logContents == (Entry1 + Entry2 + Entry3));
// from & to dates are at not at exact times an entry was made
fromDate = new MgDateTime(2005, 3, 7, 16, 52, 0, 0);
@@ -1069,7 +1052,7 @@
toDate = new MgDateTime(2005, 3, 7, 16, 56, 0, 0);
byteReader = pMgLogManager->GetErrorLog(fromDate, toDate);
logContents = MgUtil::MultiByteToWideChar(MgUtil::GetTextFromReader(byteReader));
- CPPUNIT_ASSERT(logContents == (Entry2 + Entry3 + Entry4));
+ REQUIRE(logContents == (Entry2 + Entry3 + Entry4));
// spans two different files
fromDate = new MgDateTime(2005, 3, 7, 16, 52, 0, 0);
@@ -1076,7 +1059,7 @@
toDate = new MgDateTime(2005, 3, 8, 1, 0, 0, 0);
byteReader = pMgLogManager->GetErrorLog(fromDate, toDate);
logContents = MgUtil::MultiByteToWideChar(MgUtil::GetTextFromReader(byteReader));
- CPPUNIT_ASSERT(logContents == (Entry2 + Entry3 + Entry4 + LastEntry));
+ REQUIRE(logContents == (Entry2 + Entry3 + Entry4 + LastEntry));
// spans two different files, the first of which doesn't exist
fromDate = new MgDateTime(2005, 3, 6, 23, 59, 59, 0);
@@ -1083,7 +1066,7 @@
toDate = new MgDateTime(2005, 3, 7, 16, 52, 0, 0);
byteReader = pMgLogManager->GetErrorLog(fromDate, toDate);
logContents = MgUtil::MultiByteToWideChar(MgUtil::GetTextFromReader(byteReader));
- CPPUNIT_ASSERT(logContents == Entry1);
+ REQUIRE(logContents == Entry1);
// spans two different files, the second of which doesn't exist
fromDate = new MgDateTime(2005, 3, 8, 0, 0, 0, 0);
@@ -1090,7 +1073,7 @@
toDate = new MgDateTime(2005, 3, 9, 0, 0, 0, 0);
byteReader = pMgLogManager->GetErrorLog(fromDate, toDate);
logContents = MgUtil::MultiByteToWideChar(MgUtil::GetTextFromReader(byteReader));
- CPPUNIT_ASSERT(logContents == LastEntry);
+ REQUIRE(logContents == LastEntry);
// from date is after the latest entry in the log files
fromDate = new MgDateTime(2006, 1, 1, 1, 0, 0, 0);
@@ -1097,15 +1080,15 @@
toDate = new MgDateTime(2006, 1, 1, 1, 0, 0, 0);
byteReader = pMgLogManager->GetErrorLog(fromDate, toDate);
logContents = MgUtil::MultiByteToWideChar(MgUtil::GetTextFromReader(byteReader));
- CPPUNIT_ASSERT(logContents.length() == 0);
+ REQUIRE(logContents.length() == 0);
// Use a null value for the date
- CPPUNIT_ASSERT_THROW_MG(pMgLogManager->GetErrorLog(NULL, toDate), MgNullArgumentException*);
+ REQUIRE_THROWS_MG(pMgLogManager->GetErrorLog(NULL, toDate), MgNullArgumentException*);
// Use dates more than 24 hours apart
fromDate = new MgDateTime(2005, 2, 18, 14, 0, 0, 0);
toDate = new MgDateTime(2005, 2, 19, 18, 0, 0, 0);
- CPPUNIT_ASSERT_THROW_MG(pMgLogManager->GetErrorLog(fromDate, toDate), MgInvalidArgumentException*);
+ REQUIRE_THROWS_MG(pMgLogManager->GetErrorLog(fromDate, toDate), MgInvalidArgumentException*);
pMgLogManager->SetErrorLogFileName(originalName);
}
@@ -1114,7 +1097,7 @@
pMgLogManager->SetErrorLogFileName(originalName);
STRING message = e->GetDetails(TEST_LOCALE);
SAFE_RELEASE(e);
- CPPUNIT_FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
+ FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
}
catch (...)
{
@@ -1129,10 +1112,10 @@
/// This test case tries to get the contents of the log using an invalid
/// argument. An exception should be thrown.
///----------------------------------------------------------------------------
-void TestLogManager::TestCase_GetErrorLogInvalid()
+TEST_CASE("GetErrorLogInvalid", "[LogManager]")
{
MgLogManager* pMgLogManager = MgLogManager::GetInstance();
- CPPUNIT_ASSERT_THROW_MG(pMgLogManager->GetErrorLog(-1), MgArgumentOutOfRangeException*);
+ REQUIRE_THROWS_MG(pMgLogManager->GetErrorLog(-1), MgArgumentOutOfRangeException*);
}
///----------------------------------------------------------------------------
@@ -1140,7 +1123,7 @@
///
/// This test case tries to change the log info.
///----------------------------------------------------------------------------
-void TestLogManager::TestCase_SetSessionLogInfo()
+TEST_CASE("SetSessionLogInfo", "[LogManager]")
{
try
{
@@ -1160,15 +1143,15 @@
// Restore original info
pMgLogManager->SetSessionLogInfo(bOriginalEnabled, originalName, originalParams);
- CPPUNIT_ASSERT(bEnabled == false);
- CPPUNIT_ASSERT(wcscmp(name.c_str(), TestName) == 0);
- CPPUNIT_ASSERT(wcscmp(params.c_str(), TestParameters) == 0);
+ REQUIRE(bEnabled == false);
+ REQUIRE(wcscmp(name.c_str(), TestName) == 0);
+ REQUIRE(wcscmp(params.c_str(), TestParameters) == 0);
}
catch (MgException* e)
{
STRING message = e->GetDetails(TEST_LOCALE);
SAFE_RELEASE(e);
- CPPUNIT_FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
+ FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
}
catch (...)
{
@@ -1181,19 +1164,19 @@
///
/// This test case tries to clear the log.
///----------------------------------------------------------------------------
-void TestLogManager::TestCase_ClearSessionLog()
+TEST_CASE("ClearSessionLog", "[LogManager]")
{
try
{
MgLogManager* pMgLogManager = MgLogManager::GetInstance();
bool bResult = pMgLogManager->ClearSessionLog();
- CPPUNIT_ASSERT(bResult);
+ REQUIRE(bResult);
}
catch (MgException* e)
{
STRING message = e->GetDetails(TEST_LOCALE);
SAFE_RELEASE(e);
- CPPUNIT_FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
+ FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
}
catch (...)
{
@@ -1206,7 +1189,7 @@
///
/// This test case tries to get the contents of the log.
///----------------------------------------------------------------------------
-void TestLogManager::TestCase_GetSessionLog()
+TEST_CASE("GetSessionLog", "[LogManager]")
{
MgLogManager* pMgLogManager = MgLogManager::GetInstance();
STRING path = pMgLogManager->GetLogsPath();
@@ -1232,7 +1215,7 @@
pMgLogManager->SetSessionLogFileName(originalName);
STRING message = e->GetDetails(TEST_LOCALE);
SAFE_RELEASE(e);
- CPPUNIT_FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
+ FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
}
catch (...)
{
@@ -1240,8 +1223,8 @@
throw;
}
- CPPUNIT_ASSERT(logContents == contents);
- CPPUNIT_ASSERT(lastLogEntry == LastEntry);
+ REQUIRE(logContents == contents);
+ REQUIRE(lastLogEntry == LastEntry);
}
///----------------------------------------------------------------------------
@@ -1249,7 +1232,7 @@
///
/// This test case tries to get the contents of the log between two dates.
///----------------------------------------------------------------------------
-void TestLogManager::TestCase_GetSessionLogByDate()
+TEST_CASE("GetSessionLogByDate", "[LogManager]")
{
MgLogManager* pMgLogManager = MgLogManager::GetInstance();
STRING path = pMgLogManager->GetLogsPath();
@@ -1274,7 +1257,7 @@
toDate = new MgDateTime(2005, 3, 7, 16, 54, 19, 0);
byteReader = pMgLogManager->GetSessionLog(fromDate, toDate);
logContents = MgUtil::MultiByteToWideChar(MgUtil::GetTextFromReader(byteReader));
- CPPUNIT_ASSERT(logContents == (Entry1 + Entry2 + Entry3));
+ REQUIRE(logContents == (Entry1 + Entry2 + Entry3));
// from & to dates are at not at exact times an entry was made
fromDate = new MgDateTime(2005, 3, 7, 16, 52, 0, 0);
@@ -1281,7 +1264,7 @@
toDate = new MgDateTime(2005, 3, 7, 16, 56, 0, 0);
byteReader = pMgLogManager->GetSessionLog(fromDate, toDate);
logContents = MgUtil::MultiByteToWideChar(MgUtil::GetTextFromReader(byteReader));
- CPPUNIT_ASSERT(logContents == (Entry2 + Entry3 + Entry4));
+ REQUIRE(logContents == (Entry2 + Entry3 + Entry4));
// spans two different files
fromDate = new MgDateTime(2005, 3, 7, 16, 52, 0, 0);
@@ -1288,7 +1271,7 @@
toDate = new MgDateTime(2005, 3, 8, 1, 0, 0, 0);
byteReader = pMgLogManager->GetSessionLog(fromDate, toDate);
logContents = MgUtil::MultiByteToWideChar(MgUtil::GetTextFromReader(byteReader));
- CPPUNIT_ASSERT(logContents == (Entry2 + Entry3 + Entry4 + LastEntry));
+ REQUIRE(logContents == (Entry2 + Entry3 + Entry4 + LastEntry));
// spans two different files, the first of which doesn't exist
fromDate = new MgDateTime(2005, 3, 6, 23, 59, 59, 0);
@@ -1295,7 +1278,7 @@
toDate = new MgDateTime(2005, 3, 7, 16, 52, 0, 0);
byteReader = pMgLogManager->GetSessionLog(fromDate, toDate);
logContents = MgUtil::MultiByteToWideChar(MgUtil::GetTextFromReader(byteReader));
- CPPUNIT_ASSERT(logContents == Entry1);
+ REQUIRE(logContents == Entry1);
// spans two different files, the second of which doesn't exist
fromDate = new MgDateTime(2005, 3, 8, 0, 0, 0, 0);
@@ -1302,7 +1285,7 @@
toDate = new MgDateTime(2005, 3, 9, 0, 0, 0, 0);
byteReader = pMgLogManager->GetSessionLog(fromDate, toDate);
logContents = MgUtil::MultiByteToWideChar(MgUtil::GetTextFromReader(byteReader));
- CPPUNIT_ASSERT(logContents == LastEntry);
+ REQUIRE(logContents == LastEntry);
// from date is after the latest entry in the log files
fromDate = new MgDateTime(2006, 1, 1, 1, 0, 0, 0);
@@ -1309,15 +1292,15 @@
toDate = new MgDateTime(2006, 1, 1, 1, 0, 0, 0);
byteReader = pMgLogManager->GetSessionLog(fromDate, toDate);
logContents = MgUtil::MultiByteToWideChar(MgUtil::GetTextFromReader(byteReader));
- CPPUNIT_ASSERT(logContents.length() == 0);
+ REQUIRE(logContents.length() == 0);
// Use a null value for the date
- CPPUNIT_ASSERT_THROW_MG(pMgLogManager->GetSessionLog(NULL, toDate), MgNullArgumentException*);
+ REQUIRE_THROWS_MG(pMgLogManager->GetSessionLog(NULL, toDate), MgNullArgumentException*);
// Use dates more than 24 hours apart
fromDate = new MgDateTime(2005, 2, 18, 14, 0, 0, 0);
toDate = new MgDateTime(2005, 2, 19, 18, 0, 0, 0);
- CPPUNIT_ASSERT_THROW_MG(pMgLogManager->GetSessionLog(fromDate, toDate), MgInvalidArgumentException*);
+ REQUIRE_THROWS_MG(pMgLogManager->GetSessionLog(fromDate, toDate), MgInvalidArgumentException*);
pMgLogManager->SetSessionLogFileName(originalName);
}
@@ -1326,7 +1309,7 @@
pMgLogManager->SetSessionLogFileName(originalName);
STRING message = e->GetDetails(TEST_LOCALE);
SAFE_RELEASE(e);
- CPPUNIT_FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
+ FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
}
catch (...)
{
@@ -1341,10 +1324,10 @@
/// This test case tries to get the contents of the log using an invalid
/// argument. An exception should be thrown.
///----------------------------------------------------------------------------
-void TestLogManager::TestCase_GetSessionLogInvalid()
+TEST_CASE("GetSessionLogInvalid", "[LogManager]")
{
MgLogManager* pMgLogManager = MgLogManager::GetInstance();
- CPPUNIT_ASSERT_THROW_MG(pMgLogManager->GetSessionLog(-1), MgArgumentOutOfRangeException*);
+ REQUIRE_THROWS_MG(pMgLogManager->GetSessionLog(-1), MgArgumentOutOfRangeException*);
}
///----------------------------------------------------------------------------
@@ -1352,7 +1335,7 @@
///
/// This test case tries to change the log info.
///----------------------------------------------------------------------------
-void TestLogManager::TestCase_SetTraceLogInfo()
+TEST_CASE("SetTraceLogInfo", "[LogManager]")
{
try
{
@@ -1372,15 +1355,15 @@
// Restore original info
pMgLogManager->SetTraceLogInfo(bOriginalEnabled, originalName, originalParams);
- CPPUNIT_ASSERT(bEnabled == false);
- CPPUNIT_ASSERT(wcscmp(name.c_str(), TestName) == 0);
- CPPUNIT_ASSERT(wcscmp(params.c_str(), TestParameters) == 0);
+ REQUIRE(bEnabled == false);
+ REQUIRE(wcscmp(name.c_str(), TestName) == 0);
+ REQUIRE(wcscmp(params.c_str(), TestParameters) == 0);
}
catch (MgException* e)
{
STRING message = e->GetDetails(TEST_LOCALE);
SAFE_RELEASE(e);
- CPPUNIT_FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
+ FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
}
catch (...)
{
@@ -1393,19 +1376,19 @@
///
/// This test case tries to clear the log.
///----------------------------------------------------------------------------
-void TestLogManager::TestCase_ClearTraceLog()
+TEST_CASE("ClearTraceLog", "[LogManager]")
{
try
{
MgLogManager* pMgLogManager = MgLogManager::GetInstance();
bool bResult = pMgLogManager->ClearTraceLog();
- CPPUNIT_ASSERT(bResult);
+ REQUIRE(bResult);
}
catch (MgException* e)
{
STRING message = e->GetDetails(TEST_LOCALE);
SAFE_RELEASE(e);
- CPPUNIT_FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
+ FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
}
catch (...)
{
@@ -1418,7 +1401,7 @@
///
/// This test case tries to get the contents of the log.
///----------------------------------------------------------------------------
-void TestLogManager::TestCase_GetTraceLog()
+TEST_CASE("GetTraceLog", "[LogManager]")
{
MgLogManager* pMgLogManager = MgLogManager::GetInstance();
STRING path = pMgLogManager->GetLogsPath();
@@ -1444,7 +1427,7 @@
pMgLogManager->SetTraceLogFileName(originalName);
STRING message = e->GetDetails(TEST_LOCALE);
SAFE_RELEASE(e);
- CPPUNIT_FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
+ FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
}
catch (...)
{
@@ -1452,8 +1435,8 @@
throw;
}
- CPPUNIT_ASSERT(logContents == contents);
- CPPUNIT_ASSERT(lastLogEntry == LastEntry);
+ REQUIRE(logContents == contents);
+ REQUIRE(lastLogEntry == LastEntry);
}
///----------------------------------------------------------------------------
@@ -1461,7 +1444,7 @@
///
/// This test case tries to get the contents of the log between two dates.
///----------------------------------------------------------------------------
-void TestLogManager::TestCase_GetTraceLogByDate()
+TEST_CASE("GetTraceLogByDate", "[LogManager]")
{
MgLogManager* pMgLogManager = MgLogManager::GetInstance();
STRING path = pMgLogManager->GetLogsPath();
@@ -1486,7 +1469,7 @@
toDate = new MgDateTime(2005, 3, 7, 16, 54, 19, 0);
byteReader = pMgLogManager->GetTraceLog(fromDate, toDate);
logContents = MgUtil::MultiByteToWideChar(MgUtil::GetTextFromReader(byteReader));
- CPPUNIT_ASSERT(logContents == (Entry1 + Entry2 + Entry3));
+ REQUIRE(logContents == (Entry1 + Entry2 + Entry3));
// from & to dates are at not at exact times an entry was made
fromDate = new MgDateTime(2005, 3, 7, 16, 52, 0, 0);
@@ -1493,7 +1476,7 @@
toDate = new MgDateTime(2005, 3, 7, 16, 56, 0, 0);
byteReader = pMgLogManager->GetTraceLog(fromDate, toDate);
logContents = MgUtil::MultiByteToWideChar(MgUtil::GetTextFromReader(byteReader));
- CPPUNIT_ASSERT(logContents == (Entry2 + Entry3 + Entry4));
+ REQUIRE(logContents == (Entry2 + Entry3 + Entry4));
// spans two different files
fromDate = new MgDateTime(2005, 3, 7, 16, 52, 0, 0);
@@ -1500,7 +1483,7 @@
toDate = new MgDateTime(2005, 3, 8, 1, 0, 0, 0);
byteReader = pMgLogManager->GetTraceLog(fromDate, toDate);
logContents = MgUtil::MultiByteToWideChar(MgUtil::GetTextFromReader(byteReader));
- CPPUNIT_ASSERT(logContents == (Entry2 + Entry3 + Entry4 + LastEntry));
+ REQUIRE(logContents == (Entry2 + Entry3 + Entry4 + LastEntry));
// spans two different files, the first of which doesn't exist
fromDate = new MgDateTime(2005, 3, 6, 23, 59, 59, 0);
@@ -1507,7 +1490,7 @@
toDate = new MgDateTime(2005, 3, 7, 16, 52, 0, 0);
byteReader = pMgLogManager->GetTraceLog(fromDate, toDate);
logContents = MgUtil::MultiByteToWideChar(MgUtil::GetTextFromReader(byteReader));
- CPPUNIT_ASSERT(logContents == Entry1);
+ REQUIRE(logContents == Entry1);
// spans two different files, the second of which doesn't exist
fromDate = new MgDateTime(2005, 3, 8, 0, 0, 0, 0);
@@ -1514,7 +1497,7 @@
toDate = new MgDateTime(2005, 3, 9, 0, 0, 0, 0);
byteReader = pMgLogManager->GetTraceLog(fromDate, toDate);
logContents = MgUtil::MultiByteToWideChar(MgUtil::GetTextFromReader(byteReader));
- CPPUNIT_ASSERT(logContents == LastEntry);
+ REQUIRE(logContents == LastEntry);
// from date is after the latest entry in the log files
fromDate = new MgDateTime(2006, 1, 1, 1, 0, 0, 0);
@@ -1521,15 +1504,15 @@
toDate = new MgDateTime(2006, 1, 1, 1, 0, 0, 0);
byteReader = pMgLogManager->GetTraceLog(fromDate, toDate);
logContents = MgUtil::MultiByteToWideChar(MgUtil::GetTextFromReader(byteReader));
- CPPUNIT_ASSERT(logContents.length() == 0);
+ REQUIRE(logContents.length() == 0);
// Use a null value for the date
- CPPUNIT_ASSERT_THROW_MG(pMgLogManager->GetTraceLog(NULL, toDate), MgNullArgumentException*);
+ REQUIRE_THROWS_MG(pMgLogManager->GetTraceLog(NULL, toDate), MgNullArgumentException*);
// Use dates more than 24 hours apart
fromDate = new MgDateTime(2005, 2, 18, 14, 0, 0, 0);
toDate = new MgDateTime(2005, 2, 19, 18, 0, 0, 0);
- CPPUNIT_ASSERT_THROW_MG(pMgLogManager->GetTraceLog(fromDate, toDate), MgInvalidArgumentException*);
+ REQUIRE_THROWS_MG(pMgLogManager->GetTraceLog(fromDate, toDate), MgInvalidArgumentException*);
pMgLogManager->SetTraceLogFileName(originalName);
}
@@ -1538,7 +1521,7 @@
pMgLogManager->SetTraceLogFileName(originalName);
STRING message = e->GetDetails(TEST_LOCALE);
SAFE_RELEASE(e);
- CPPUNIT_FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
+ FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
}
catch (...)
{
@@ -1553,10 +1536,10 @@
/// This test case tries to get the contents of the log using an invalid
/// argument. An exception should be thrown.
///----------------------------------------------------------------------------
-void TestLogManager::TestCase_GetTraceLogInvalid()
+TEST_CASE("GetTraceLogInvalid", "[LogManager]")
{
MgLogManager* pMgLogManager = MgLogManager::GetInstance();
- CPPUNIT_ASSERT_THROW_MG(pMgLogManager->GetTraceLog(-1), MgArgumentOutOfRangeException*);
+ REQUIRE_THROWS_MG(pMgLogManager->GetTraceLog(-1), MgArgumentOutOfRangeException*);
}
///----------------------------------------------------------------------------
@@ -1564,7 +1547,7 @@
///
/// This test case writes an entry to the log. (Assumes that getlog works)
///----------------------------------------------------------------------------
-void TestLogManager::TestCase_LogAccessEntry()
+TEST_CASE("LogAccessEntry", "[LogManager]")
{
Ptr<MgByteReader> byteReader;
STRING logEntry;
@@ -1591,7 +1574,7 @@
{
STRING message = e->GetDetails(TEST_LOCALE);
SAFE_RELEASE(e);
- CPPUNIT_FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
+ FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
}
catch (...)
@@ -1600,7 +1583,7 @@
}
pos = logEntry.find(entry);
- CPPUNIT_ASSERT(pos != string::npos);
+ REQUIRE(pos != string::npos);
}
///----------------------------------------------------------------------------
@@ -1608,7 +1591,7 @@
///
/// This test case writes an entry to the log. (Assumes that getlog works)
///----------------------------------------------------------------------------
-void TestLogManager::TestCase_LogAdminEntry()
+TEST_CASE("LogAdminEntry", "[LogManager]")
{
Ptr<MgByteReader> byteReader;
STRING logEntry;
@@ -1635,7 +1618,7 @@
{
STRING message = e->GetDetails(TEST_LOCALE);
SAFE_RELEASE(e);
- CPPUNIT_FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
+ FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
}
catch (...)
{
@@ -1643,7 +1626,7 @@
}
pos = logEntry.find(entry);
- CPPUNIT_ASSERT(pos != string::npos);
+ REQUIRE(pos != string::npos);
}
///----------------------------------------------------------------------------
@@ -1651,7 +1634,7 @@
///
/// This test case writes an entry to the log. (Assumes that getlog works)
///----------------------------------------------------------------------------
-void TestLogManager::TestCase_LogAuthenticationEntry()
+TEST_CASE("LogAuthenticationEntry", "[LogManager]")
{
Ptr<MgByteReader> byteReader;
STRING logEntry;
@@ -1678,7 +1661,7 @@
{
STRING message = e->GetDetails(TEST_LOCALE);
SAFE_RELEASE(e);
- CPPUNIT_FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
+ FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
}
catch (...)
{
@@ -1686,7 +1669,7 @@
}
pos = logEntry.find(entry);
- CPPUNIT_ASSERT(pos != string::npos);
+ REQUIRE(pos != string::npos);
}
///----------------------------------------------------------------------------
@@ -1694,7 +1677,7 @@
///
/// This test case writes an entry to the log. (Assumes that getlog works)
///----------------------------------------------------------------------------
-void TestLogManager::TestCase_LogErrorEntry()
+TEST_CASE("LogErrorEntry", "[LogManager]")
{
Ptr<MgByteReader> byteReader;
STRING logEntry;
@@ -1721,7 +1704,7 @@
{
STRING message = e->GetDetails(TEST_LOCALE);
SAFE_RELEASE(e);
- CPPUNIT_FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
+ FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
}
catch (...)
{
@@ -1729,7 +1712,7 @@
}
pos = logEntry.find(entry);
- CPPUNIT_ASSERT(pos != string::npos);
+ REQUIRE(pos != string::npos);
}
///----------------------------------------------------------------------------
@@ -1737,7 +1720,7 @@
///
/// This test case writes an entry to the log. (Assumes that getlog works)
///----------------------------------------------------------------------------
-void TestLogManager::TestCase_LogSessionEntry()
+TEST_CASE("LogSessionEntry", "[LogManager]")
{
STRING logEntry;
MgSessionInfo sessionInfo;
@@ -1762,7 +1745,7 @@
{
STRING message = e->GetDetails(TEST_LOCALE);
SAFE_RELEASE(e);
- CPPUNIT_FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
+ FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
}
catch (...)
{
@@ -1772,7 +1755,7 @@
// Find the values for ops failed and received, 0 and 0 respectively,
// since no session object has been created.
- CPPUNIT_ASSERT(STRING::npos != logEntry.find(L"\t0\t0"));
+ REQUIRE(STRING::npos != logEntry.find(L"\t0\t0"));
}
///----------------------------------------------------------------------------
@@ -1780,7 +1763,7 @@
///
/// This test case writes an entry to the log. (Assumes that getlog works)
///----------------------------------------------------------------------------
-void TestLogManager::TestCase_LogTraceEntry()
+TEST_CASE("LogTraceEntry", "[LogManager]")
{
Ptr<MgByteReader> byteReader;
STRING logEntry;
@@ -1807,7 +1790,7 @@
{
STRING message = e->GetDetails(TEST_LOCALE);
SAFE_RELEASE(e);
- CPPUNIT_FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
+ FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
}
catch (...)
{
@@ -1815,7 +1798,7 @@
}
pos = logEntry.find(entry);
- CPPUNIT_ASSERT(pos != string::npos);
+ REQUIRE(pos != string::npos);
}
@@ -1824,7 +1807,7 @@
///
/// This test case tries to get the contents of the specified log.
///----------------------------------------------------------------------------
-void TestLogManager::TestCase_GetLogFile()
+TEST_CASE("GetLogFile", "[LogManager]")
{
MgLogManager* pMgLogManager = MgLogManager::GetInstance();
STRING path = pMgLogManager->GetLogsPath();
@@ -1850,7 +1833,7 @@
pMgLogManager->SetAccessLogFileName(originalName);
STRING message = e->GetDetails(TEST_LOCALE);
SAFE_RELEASE(e);
- CPPUNIT_FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
+ FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
}
catch (...)
{
@@ -1858,5 +1841,5 @@
throw;
}
- CPPUNIT_ASSERT(logContents == contents);
+ REQUIRE(logContents == contents);
}
Deleted: sandbox/jng/catch2/Server/src/UnitTesting/TestLogManager.h
===================================================================
--- sandbox/jng/catch2/Server/src/UnitTesting/TestLogManager.h 2020-07-07 15:57:41 UTC (rev 9656)
+++ sandbox/jng/catch2/Server/src/UnitTesting/TestLogManager.h 2020-07-08 11:10:16 UTC (rev 9657)
@@ -1,146 +0,0 @@
-//
-// 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 _TESTLOGMANAGER_H
-#define _TESTLOGMANAGER_H
-
-#include <cppunit/extensions/HelperMacros.h>
-
-class TestLogManager : public CppUnit::TestFixture
-{
- CPPUNIT_TEST_SUITE(TestLogManager);
- CPPUNIT_TEST(TestStart); // This must be the very first unit test
-
- CPPUNIT_TEST(TestCase_ValidLogManager);
- CPPUNIT_TEST(TestCase_GetLogsPath);
- CPPUNIT_TEST(TestCase_TestForDeadLock);
-
- CPPUNIT_TEST(TestCase_EnumerateLogs);
- CPPUNIT_TEST(TestCase_RenameLog);
-
- CPPUNIT_TEST(TestCase_SetAccessLogInfo);
- CPPUNIT_TEST(TestCase_ClearAccessLog);
- CPPUNIT_TEST(TestCase_GetAccessLog);
- CPPUNIT_TEST(TestCase_GetAccessLogByDate);
- CPPUNIT_TEST(TestCase_GetAccessLogInvalid);
-
- CPPUNIT_TEST(TestCase_SetAdminLogInfo);
- CPPUNIT_TEST(TestCase_ClearAdminLog);
- CPPUNIT_TEST(TestCase_GetAdminLog);
- CPPUNIT_TEST(TestCase_GetAdminLogByDate);
- CPPUNIT_TEST(TestCase_GetAdminLogInvalid);
-
- CPPUNIT_TEST(TestCase_SetAuthenticationLogInfo);
- CPPUNIT_TEST(TestCase_ClearAuthenticationLog);
- CPPUNIT_TEST(TestCase_GetAuthenticationLog);
- CPPUNIT_TEST(TestCase_GetAuthenticationLogByDate);
- CPPUNIT_TEST(TestCase_GetAuthenticationLogInvalid);
-
- CPPUNIT_TEST(TestCase_SetErrorLogInfo);
- CPPUNIT_TEST(TestCase_ClearErrorLog);
- CPPUNIT_TEST(TestCase_GetErrorLog);
- CPPUNIT_TEST(TestCase_GetErrorLogByDate);
- CPPUNIT_TEST(TestCase_GetErrorLogInvalid);
-
- CPPUNIT_TEST(TestCase_SetSessionLogInfo);
- CPPUNIT_TEST(TestCase_ClearSessionLog);
- CPPUNIT_TEST(TestCase_GetSessionLog);
- CPPUNIT_TEST(TestCase_GetSessionLogByDate);
- CPPUNIT_TEST(TestCase_GetSessionLogInvalid);
-
- CPPUNIT_TEST(TestCase_SetTraceLogInfo);
- CPPUNIT_TEST(TestCase_ClearTraceLog);
- CPPUNIT_TEST(TestCase_GetTraceLog);
- CPPUNIT_TEST(TestCase_GetTraceLogByDate);
- CPPUNIT_TEST(TestCase_GetTraceLogInvalid);
-
- CPPUNIT_TEST(TestCase_LogAccessEntry);
- CPPUNIT_TEST(TestCase_LogAdminEntry);
- CPPUNIT_TEST(TestCase_LogAuthenticationEntry);
- CPPUNIT_TEST(TestCase_LogErrorEntry);
- CPPUNIT_TEST(TestCase_LogSessionEntry);
- CPPUNIT_TEST(TestCase_LogTraceEntry);
-
- CPPUNIT_TEST(TestCase_GetLogFile);
-
- CPPUNIT_TEST(TestCase_DeleteLog);
-
- CPPUNIT_TEST(TestEnd); // This must be the very last unit test
- CPPUNIT_TEST_SUITE_END();
-
-public:
- void setUp();
- void tearDown();
- void TestStart();
- void TestEnd();
- bool CreateFile(STRING filename, STRING contents);
-
- void TestCase_ValidLogManager();
- void TestCase_GetLogsPath();
- void TestCase_TestForDeadLock();
-
- void TestCase_EnumerateLogs();
- void TestCase_DeleteLog();
- void TestCase_RenameLog();
-
- void TestCase_SetAccessLogInfo();
- void TestCase_ClearAccessLog();
- void TestCase_GetAccessLog();
- void TestCase_GetAccessLogByDate();
- void TestCase_GetAccessLogInvalid();
-
- void TestCase_SetAdminLogInfo();
- void TestCase_ClearAdminLog();
- void TestCase_GetAdminLog();
- void TestCase_GetAdminLogByDate();
- void TestCase_GetAdminLogInvalid();
-
- void TestCase_SetAuthenticationLogInfo();
- void TestCase_ClearAuthenticationLog();
- void TestCase_GetAuthenticationLog();
- void TestCase_GetAuthenticationLogByDate();
- void TestCase_GetAuthenticationLogInvalid();
-
- void TestCase_SetErrorLogInfo();
- void TestCase_ClearErrorLog();
- void TestCase_GetErrorLog();
- void TestCase_GetErrorLogByDate();
- void TestCase_GetErrorLogInvalid();
-
- void TestCase_SetSessionLogInfo();
- void TestCase_ClearSessionLog();
- void TestCase_GetSessionLog();
- void TestCase_GetSessionLogByDate();
- void TestCase_GetSessionLogInvalid();
-
- void TestCase_SetTraceLogInfo();
- void TestCase_ClearTraceLog();
- void TestCase_GetTraceLog();
- void TestCase_GetTraceLogByDate();
- void TestCase_GetTraceLogInvalid();
-
- void TestCase_LogAccessEntry();
- void TestCase_LogAdminEntry();
- void TestCase_LogAuthenticationEntry();
- void TestCase_LogErrorEntry();
- void TestCase_LogSessionEntry();
- void TestCase_LogTraceEntry();
-
- void TestCase_GetLogFile();
-};
-
-#endif // _TESTLOGMANAGER_H
Modified: sandbox/jng/catch2/Server/src/UnitTesting/TestMappingService.cpp
===================================================================
--- sandbox/jng/catch2/Server/src/UnitTesting/TestMappingService.cpp 2020-07-07 15:57:41 UTC (rev 9656)
+++ sandbox/jng/catch2/Server/src/UnitTesting/TestMappingService.cpp 2020-07-08 11:10:16 UTC (rev 9657)
@@ -16,324 +16,25 @@
//
#include "MapGuideCommon.h"
-#include "TestMappingService.h"
#include "ServiceManager.h"
#include "ServerResourceService.h"
#include "ServerMappingService.h"
#include "ServerSiteService.h"
-#include "../Common/Manager/FdoConnectionManager.h"
-#include "CppUnitExtensions.h"
+#include "CatchHelperMacros.h"
#include "FoundationDefs.h"
-const STRING TEST_LOCALE = L"en";
+#include "TestServiceFactory.h"
+#include "catch.hpp"
-CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(TestMappingService, "TestMappingService");
-
-TestMappingService::TestMappingService()
+static void TestCase_CreateRuntimeMap(INT32 major, INT32 minor, INT32 rev)
{
- // Initialize service objects.
- MgServiceManager* serviceManager = MgServiceManager::GetInstance();
-
- m_svcResource = dynamic_cast<MgResourceService*>(
- serviceManager->RequestService(MgServiceType::ResourceService));
- assert(m_svcResource != NULL);
-
- m_svcMapping = dynamic_cast<MgMappingService*>(
- serviceManager->RequestService(MgServiceType::MappingService));
- assert(m_svcMapping != NULL);
-
- // Initialize a site connection.
- Ptr<MgServerSiteService> svcSite = dynamic_cast<MgServerSiteService*>(
- serviceManager->RequestService(MgServiceType::SiteService));
- assert(svcSite != NULL);
-
- Ptr<MgUserInformation> userInfo = new MgUserInformation(
- L"Administrator", L"admin");
- userInfo->SetLocale(TEST_LOCALE);
-
- // Set the current MgUserInformation
- // This must be done before calling CreateSession()
- MgUserInformation::SetCurrentUserInfo(userInfo);
-
- m_session = svcSite->CreateSession();
- assert(!m_session.empty());
- userInfo->SetMgSessionId(m_session);
-
- // Set the current MgUserInformation
- MgUserInformation::SetCurrentUserInfo(userInfo);
-
- m_siteConnection = new MgSiteConnection();
- m_siteConnection->Open(userInfo);
-}
-
-
-TestMappingService::~TestMappingService()
-{
-}
-
-
-void TestMappingService::setUp()
-{
-}
-
-
-void TestMappingService::tearDown()
-{
-}
-
-
-void TestMappingService::TestStart()
-{
- ACE_DEBUG((LM_INFO, ACE_TEXT("\nRunning Mapping Service tests.\n")));
-
try
{
- #ifdef _DEBUG
- MgFdoConnectionManager* pFdoConnectionManager = MgFdoConnectionManager::GetInstance();
- if(pFdoConnectionManager)
- {
- pFdoConnectionManager->ShowCache();
- }
- #endif
+ STRING m_session;
+ Ptr<MgServerSiteService> svcSite = TestServiceFactory::CreateSiteService();
+ Ptr<MgUserInformation> userInfo = TestServiceFactory::CreateSession(svcSite, m_session, L"Administrator", L"admin");
+ Ptr<MgMappingService> m_svcMapping = TestServiceFactory::CreateMappingService();
- //set user info
- Ptr<MgUserInformation> userInfo = new MgUserInformation(L"Administrator", L"admin");
- userInfo->SetLocale(TEST_LOCALE);
- MgUserInformation::SetCurrentUserInfo(userInfo);
-
- //publish the map definition
- Ptr<MgResourceIdentifier> mapres = new MgResourceIdentifier(L"Library://UnitTests/Maps/Sheboygan.MapDefinition");
- Ptr<MgByteSource> mdfsrc = new MgByteSource(L"../UnitTestFiles/UT_Sheboygan.mdf", false);
- Ptr<MgByteReader> mdfrdr = mdfsrc->GetReader();
- m_svcResource->SetResource(mapres, mdfrdr, NULL);
-
- //publish the layer definitions
- Ptr<MgResourceIdentifier> ldfres1 = new MgResourceIdentifier(L"Library://UnitTests/Layers/HydrographicPolygons.LayerDefinition");
- Ptr<MgByteSource> ldfsrc1 = new MgByteSource(L"../UnitTestFiles/UT_HydrographicPolygons.ldf", false);
- Ptr<MgByteReader> ldfrdr1 = ldfsrc1->GetReader();
- m_svcResource->SetResource(ldfres1, ldfrdr1, NULL);
-
- Ptr<MgResourceIdentifier> ldfres2 = new MgResourceIdentifier(L"Library://UnitTests/Layers/Parcels.LayerDefinition");
- Ptr<MgByteSource> ldfsrc2 = new MgByteSource(L"../UnitTestFiles/UT_Parcels.ldf", false);
- Ptr<MgByteReader> ldfrdr2 = ldfsrc2->GetReader();
- m_svcResource->SetResource(ldfres2, ldfrdr2, NULL);
-
- Ptr<MgResourceIdentifier> ldfres3 = new MgResourceIdentifier(L"Library://UnitTests/Layers/Rail.LayerDefinition");
- Ptr<MgByteSource> ldfsrc3 = new MgByteSource(L"../UnitTestFiles/UT_Rail.ldf", false);
- Ptr<MgByteReader> ldfrdr3 = ldfsrc3->GetReader();
- m_svcResource->SetResource(ldfres3, ldfrdr3, NULL);
-
- Ptr<MgResourceIdentifier> ldfres4 = new MgResourceIdentifier(L"Library://UnitTests/Layers/RotatedPointStyles.LayerDefinition");
- Ptr<MgByteSource> ldfsrc4 = new MgByteSource(L"../UnitTestFiles/UT_RotatedPointStyles.ldf", false);
- Ptr<MgByteReader> ldfrdr4 = ldfsrc4->GetReader();
- m_svcResource->SetResource(ldfres4, ldfrdr4, NULL);
-
- Ptr<MgResourceIdentifier> ldfres5 = new MgResourceIdentifier(L"Library://UnitTests/Layers/RoadCenterLines.LayerDefinition");
- Ptr<MgByteSource> ldfsrc5 = new MgByteSource(L"../UnitTestFiles/UT_RoadCenterLines.ldf", false);
- Ptr<MgByteReader> ldfrdr5 = ldfsrc5->GetReader();
- m_svcResource->SetResource(ldfres5, ldfrdr5, NULL);
-
- Ptr<MgResourceIdentifier> ldfres6 = new MgResourceIdentifier(L"Library://UnitTests/Layers/VotingDistricts.LayerDefinition");
- Ptr<MgByteSource> ldfsrc6 = new MgByteSource(L"../UnitTestFiles/UT_VotingDistricts.ldf", false);
- Ptr<MgByteReader> ldfrdr6 = ldfsrc6->GetReader();
- m_svcResource->SetResource(ldfres6, ldfrdr6, NULL);
-
- Ptr<MgResourceIdentifier> ldfres7 = new MgResourceIdentifier(L"Library://UnitTests/Layers/MultiCTS.LayerDefinition");
- Ptr<MgByteSource> ldfsrc7 = new MgByteSource(L"../UnitTestFiles/UT_MultiCTS.ldf", false);
- Ptr<MgByteReader> ldfrdr7 = ldfsrc7->GetReader();
- m_svcResource->SetResource(ldfres7, ldfrdr7, NULL);
-
- Ptr<MgResourceIdentifier> ldfres8 = new MgResourceIdentifier(L"Library://UnitTests/Layers/MultiCTSWithTheme.LayerDefinition");
- Ptr<MgByteSource> ldfsrc8 = new MgByteSource(L"../UnitTestFiles/UT_MultiCTSWithTheme.ldf", false);
- Ptr<MgByteReader> ldfrdr8 = ldfsrc8->GetReader();
- m_svcResource->SetResource(ldfres8, ldfrdr8, NULL);
-
- //publish the feature sources
- Ptr<MgResourceIdentifier> fsres1 = new MgResourceIdentifier(L"Library://UnitTests/Data/HydrographicPolygons.FeatureSource");
- Ptr<MgByteSource> fssrc1 = new MgByteSource(L"../UnitTestFiles/UT_HydrographicPolygons.fs", false);
- Ptr<MgByteReader> fsrdr1 = fssrc1->GetReader();
- m_svcResource->SetResource(fsres1, fsrdr1, NULL);
-
- Ptr<MgResourceIdentifier> fsres2 = new MgResourceIdentifier(L"Library://UnitTests/Data/Parcels.FeatureSource");
- Ptr<MgByteSource> fssrc2 = new MgByteSource(L"../UnitTestFiles/UT_Parcels.fs", false);
- Ptr<MgByteReader> fsrdr2 = fssrc2->GetReader();
- m_svcResource->SetResource(fsres2, fsrdr2, NULL);
-
- Ptr<MgResourceIdentifier> fsres3 = new MgResourceIdentifier(L"Library://UnitTests/Data/Rail.FeatureSource");
- Ptr<MgByteSource> fssrc3 = new MgByteSource(L"../UnitTestFiles/UT_Rail.fs", false);
- Ptr<MgByteReader> fsrdr3 = fssrc3->GetReader();
- m_svcResource->SetResource(fsres3, fsrdr3, NULL);
-
- // publish the resource data
- Ptr<MgByteSource> dataSource1 = new MgByteSource(L"../UnitTestFiles/UT_HydrographicPolygons.sdf", false);
- Ptr<MgByteReader> dataReader1 = dataSource1->GetReader();
- m_svcResource->SetResourceData(fsres1, L"UT_HydrographicPolygons.sdf", L"File", dataReader1);
-
- Ptr<MgByteSource> dataSource2 = new MgByteSource(L"../UnitTestFiles/UT_Parcels.sdf", false);
- Ptr<MgByteReader> dataReader2 = dataSource2->GetReader();
- m_svcResource->SetResourceData(fsres2, L"UT_Parcels.sdf", L"File", dataReader2);
-
- Ptr<MgByteSource> dataSource3 = new MgByteSource(L"../UnitTestFiles/UT_Rail.sdf", false);
- Ptr<MgByteReader> dataReader3 = dataSource3->GetReader();
- m_svcResource->SetResourceData(fsres3, L"UT_Rail.sdf", L"File", dataReader3);
-
- // publish the print layouts
- Ptr<MgResourceIdentifier> plres1 = new MgResourceIdentifier(L"Library://UnitTests/PrintLayouts/AllElements.PrintLayout");
- Ptr<MgByteSource> plsrc1 = new MgByteSource(L"../UnitTestFiles/UT_AllElements.pl", false);
- Ptr<MgByteReader> plrdr1 = plsrc1->GetReader();
- m_svcResource->SetResource(plres1, plrdr1, NULL);
-
- Ptr<MgResourceIdentifier> plres2 = new MgResourceIdentifier(L"Library://UnitTests/PrintLayouts/NoLegend.PrintLayout");
- Ptr<MgByteSource> plsrc2 = new MgByteSource(L"../UnitTestFiles/UT_NoLegend.pl", false);
- Ptr<MgByteReader> plrdr2 = plsrc2->GetReader();
- m_svcResource->SetResource(plres2, plrdr2, NULL);
-
- // publish the symbol library
- Ptr<MgResourceIdentifier> slres1 = new MgResourceIdentifier(L"Library://UnitTests/Symbols/SymbolMart.SymbolLibrary");
- Ptr<MgByteSource> slsrc1 = new MgByteSource(L"../UnitTestFiles/UT_SymbolMart.sl", false);
- Ptr<MgByteReader> slrdr1 = slsrc1->GetReader();
- m_svcResource->SetResource(slres1, slrdr1, NULL);
- Ptr<MgByteSource> datasrc = new MgByteSource(L"../UnitTestFiles/UT_Symbols.dwf", false);
- Ptr<MgByteReader> datardr = datasrc->GetReader();
- m_svcResource->SetResourceData(slres1, L"symbols.dwf", L"File", datardr);
-
- Ptr<MgResourceIdentifier> mapres2 = new MgResourceIdentifier(L"Library://UnitTests/Maps/LinkedTileSet.MapDefinition");
- Ptr<MgByteSource> mdfsrc2 = new MgByteSource(L"../UnitTestFiles/UT_LinkedTileSet.mdf", false);
- Ptr<MgByteReader> mdfrdr2 = mdfsrc2->GetReader();
- m_svcResource->SetResource(mapres2, mdfrdr2, NULL);
-
- Ptr<MgResourceIdentifier> mapres3 = new MgResourceIdentifier(L"Library://UnitTests/Maps/LinkedTileSetXYZ.MapDefinition");
- Ptr<MgByteSource> mdfsrc3 = new MgByteSource(L"../UnitTestFiles/UT_LinkedTileSetXYZ.mdf", false);
- Ptr<MgByteReader> mdfrdr3 = mdfsrc3->GetReader();
- m_svcResource->SetResource(mapres3, mdfrdr3, NULL);
-
- Ptr<MgResourceIdentifier> tilesetres1 = new MgResourceIdentifier(L"Library://UnitTests/TileSets/Sheboygan.TileSetDefinition");
- Ptr<MgByteSource> tsdsrc1 = new MgByteSource(L"../UnitTestFiles/UT_BaseMap.tsd", false);
- Ptr<MgByteReader> tsdrdr1 = tsdsrc1->GetReader();
- m_svcResource->SetResource(tilesetres1, tsdrdr1, NULL);
-
- Ptr<MgResourceIdentifier> tilesetres2 = new MgResourceIdentifier(L"Library://UnitTests/TileSets/XYZ.TileSetDefinition");
- Ptr<MgByteSource> tsdsrc2 = new MgByteSource(L"../UnitTestFiles/UT_XYZ.tsd", false);
- Ptr<MgByteReader> tsdrdr2 = tsdsrc2->GetReader();
- m_svcResource->SetResource(tilesetres2, tsdrdr2, NULL);
-
- Ptr<MgByteSource> bsPackage = new MgByteSource(L"../UnitTestFiles/PlotHole.mgp", false);
- Ptr<MgByteReader> pkgReader = bsPackage->GetReader();
- m_svcResource->ApplyResourcePackage(pkgReader);
- }
- catch (MgException* e)
- {
- STRING message = e->GetDetails(TEST_LOCALE);
- SAFE_RELEASE(e);
- CPPUNIT_FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
- }
- catch (...)
- {
- throw;
- }
-}
-
-
-void TestMappingService::TestEnd()
-{
- try
- {
- //set user info
- Ptr<MgUserInformation> userInfo = new MgUserInformation(L"Administrator", L"admin");
- userInfo->SetLocale(TEST_LOCALE);
- MgUserInformation::SetCurrentUserInfo(userInfo);
-
- //delete the map definition
- Ptr<MgResourceIdentifier> mapres = new MgResourceIdentifier(L"Library://UnitTests/Maps/Sheboygan.MapDefinition");
- m_svcResource->DeleteResource(mapres);
-
- //delete the layer definitions
- Ptr<MgResourceIdentifier> ldfres1 = new MgResourceIdentifier(L"Library://UnitTests/Layers/HydrographicPolygons.LayerDefinition");
- m_svcResource->DeleteResource(ldfres1);
-
- Ptr<MgResourceIdentifier> ldfres2 = new MgResourceIdentifier(L"Library://UnitTests/Layers/Parcels.LayerDefinition");
- m_svcResource->DeleteResource(ldfres2);
-
- Ptr<MgResourceIdentifier> ldfres3 = new MgResourceIdentifier(L"Library://UnitTests/Layers/Rail.LayerDefinition");
- m_svcResource->DeleteResource(ldfres3);
-
- Ptr<MgResourceIdentifier> ldfres4 = new MgResourceIdentifier(L"Library://UnitTests/Layers/RotatedPointStyles.LayerDefinition");
- m_svcResource->DeleteResource(ldfres4);
-
- Ptr<MgResourceIdentifier> ldfres5 = new MgResourceIdentifier(L"Library://UnitTests/Layers/RoadCenterLines.LayerDefinition");
- m_svcResource->DeleteResource(ldfres5);
-
- Ptr<MgResourceIdentifier> ldfres6 = new MgResourceIdentifier(L"Library://UnitTests/Layers/VotingDistricts.LayerDefinition");
- m_svcResource->DeleteResource(ldfres6);
-
- Ptr<MgResourceIdentifier> ldfres7 = new MgResourceIdentifier(L"Library://UnitTests/Layers/MultiCTS.LayerDefinition");
- m_svcResource->DeleteResource(ldfres7);
-
- Ptr<MgResourceIdentifier> ldfres8 = new MgResourceIdentifier(L"Library://UnitTests/Layers/MultiCTSWithTheme.LayerDefinition");
- m_svcResource->DeleteResource(ldfres8);
-
- //delete the feature sources
- Ptr<MgResourceIdentifier> fsres1 = new MgResourceIdentifier(L"Library://UnitTests/Data/HydrographicPolygons.FeatureSource");
- m_svcResource->DeleteResource(fsres1);
-
- Ptr<MgResourceIdentifier> fsres2 = new MgResourceIdentifier(L"Library://UnitTests/Data/Parcels.FeatureSource");
- m_svcResource->DeleteResource(fsres2);
-
- Ptr<MgResourceIdentifier> fsres3 = new MgResourceIdentifier(L"Library://UnitTests/Data/Rail.FeatureSource");
- m_svcResource->DeleteResource(fsres3);
-
- // delete the print layouts
- Ptr<MgResourceIdentifier> plres1 = new MgResourceIdentifier(L"Library://UnitTests/PrintLayouts/AllElements.PrintLayout");
- m_svcResource->DeleteResource(plres1);
-
- Ptr<MgResourceIdentifier> plres2 = new MgResourceIdentifier(L"Library://UnitTests/PrintLayouts/NoLegend.PrintLayout");
- m_svcResource->DeleteResource(plres2);
-
- // delete the symbol library
- Ptr<MgResourceIdentifier> slres1 = new MgResourceIdentifier(L"Library://UnitTests/Symbols/SymbolMart.SymbolLibrary");
- m_svcResource->DeleteResource(slres1);
-
- Ptr<MgResourceIdentifier> mapres2 = new MgResourceIdentifier(L"Library://UnitTests/Maps/LinkedTileSet.MapDefinition");
- m_svcResource->DeleteResource(mapres2);
-
- Ptr<MgResourceIdentifier> mapres3 = new MgResourceIdentifier(L"Library://UnitTests/Maps/LinkedTileSetXYZ.MapDefinition");
- m_svcResource->DeleteResource(mapres3);
-
- Ptr<MgResourceIdentifier> tilesetres1 = new MgResourceIdentifier(L"Library://UnitTests/TileSets/Sheboygan.TileSetDefinition");
- m_svcResource->DeleteResource(tilesetres1);
-
- Ptr<MgResourceIdentifier> tilesetres2 = new MgResourceIdentifier(L"Library://UnitTests/TileSets/XYZ.TileSetDefinition");
- m_svcResource->DeleteResource(tilesetres2);
-
- Ptr<MgResourceIdentifier> plotHoleFolder = new MgResourceIdentifier(L"Library://UnitTests/PlotHole/");
- m_svcResource->DeleteResource(plotHoleFolder);
-
- #ifdef _DEBUG
- MgFdoConnectionManager* pFdoConnectionManager = MgFdoConnectionManager::GetInstance();
- if(pFdoConnectionManager)
- {
- pFdoConnectionManager->ShowCache();
- }
- #endif
- }
- catch (MgException* e)
- {
- STRING message = e->GetDetails(TEST_LOCALE);
- SAFE_RELEASE(e);
- CPPUNIT_FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
- }
- catch (...)
- {
- throw;
- }
-
- ACE_DEBUG((LM_INFO, ACE_TEXT("\nMapping Service tests completed.\n\n")));
-}
-
-void TestMappingService::TestCase_CreateRuntimeMap(INT32 major, INT32 minor, INT32 rev)
-{
- try
- {
STRING suffix = L"_";
STRING s;
MgUtil::Int32ToString(major, s);
@@ -448,9 +149,9 @@
}
catch(MgException* e)
{
- STRING message = e->GetDetails(TEST_LOCALE);
+ STRING message = e->GetDetails(TestServiceFactory::TEST_LOCALE);
SAFE_RELEASE(e);
- CPPUNIT_FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
+ FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
}
catch(...)
{
@@ -458,10 +159,16 @@
}
}
-void TestMappingService::TestCase_DescribeRuntimeMap()
+TEST_CASE("DescribeRuntimeMap", "[MappingService]")
{
try
{
+ STRING m_session;
+ Ptr<MgServerSiteService> svcSite = TestServiceFactory::CreateSiteService();
+ Ptr<MgUserInformation> userInfo = TestServiceFactory::CreateSession(svcSite, m_session, L"Administrator", L"admin");
+ Ptr<MgMappingService> m_svcMapping = TestServiceFactory::CreateMappingService();
+ Ptr<MgSiteConnection> m_siteConnection = TestServiceFactory::CreateSiteConnection(svcSite, m_session);
+
//make a runtime map
Ptr<MgResourceIdentifier> mdfres = new MgResourceIdentifier(L"Library://UnitTests/Maps/Sheboygan.MapDefinition");
STRING format = MgImageFormats::Png;
@@ -550,9 +257,9 @@
}
catch(MgException* e)
{
- STRING message = e->GetDetails(TEST_LOCALE);
+ STRING message = e->GetDetails(TestServiceFactory::TEST_LOCALE);
SAFE_RELEASE(e);
- CPPUNIT_FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
+ FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
}
catch(...)
{
@@ -560,10 +267,16 @@
}
}
-void TestMappingService::TestCase_CreateAndDescribeLinkedRuntimeMap()
+TEST_CASE("CreateAndDescribeLinkedRuntimeMap", "[MappingService]")
{
try
{
+ STRING m_session;
+ Ptr<MgServerSiteService> svcSite = TestServiceFactory::CreateSiteService();
+ Ptr<MgUserInformation> userInfo = TestServiceFactory::CreateSession(svcSite, m_session, L"Administrator", L"admin");
+ Ptr<MgMappingService> m_svcMapping = TestServiceFactory::CreateMappingService();
+ Ptr<MgSiteConnection> m_siteConnection = TestServiceFactory::CreateSiteConnection(svcSite, m_session);
+
Ptr<MgResourceIdentifier> mdfId = new MgResourceIdentifier(L"Library://UnitTests/Maps/LinkedTileSet.MapDefinition");
STRING format = MgImageFormats::Png;
Ptr<MgByteReader> rtMap = m_svcMapping->CreateRuntimeMap(mdfId, L"TestCase_CreateAndDescribeLinkedRuntimeMap", m_session, format, 16, 16, 0, 25);
@@ -578,9 +291,9 @@
}
catch(MgException* e)
{
- STRING message = e->GetDetails(TEST_LOCALE);
+ STRING message = e->GetDetails(TestServiceFactory::TEST_LOCALE);
SAFE_RELEASE(e);
- CPPUNIT_FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
+ FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
}
catch(...)
{
@@ -587,10 +300,17 @@
throw;
}
}
-void TestMappingService::TestCase_SaveMap()
+
+TEST_CASE("SaveMap", "[MappingService]")
{
try
{
+ STRING m_session;
+ Ptr<MgServerSiteService> svcSite = TestServiceFactory::CreateSiteService();
+ Ptr<MgUserInformation> userInfo = TestServiceFactory::CreateSession(svcSite, m_session, L"Administrator", L"admin");
+ Ptr<MgMappingService> m_svcMapping = TestServiceFactory::CreateMappingService();
+ Ptr<MgSiteConnection> m_siteConnection = TestServiceFactory::CreateSiteConnection(svcSite, m_session);
+
// Create a runtime map, save it, then open it.
Ptr<MgResourceIdentifier> mapDefId = new MgResourceIdentifier(L"Library://UnitTests/Maps/Sheboygan.MapDefinition");
STRING mapName = L"UnitTestSheboygan";
@@ -605,9 +325,9 @@
}
catch (MgException* e)
{
- STRING message = e->GetDetails(TEST_LOCALE);
+ STRING message = e->GetDetails(TestServiceFactory::TEST_LOCALE);
SAFE_RELEASE(e);
- CPPUNIT_FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
+ FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
}
catch (...)
{
@@ -615,10 +335,16 @@
}
}
-void TestMappingService::TestCase_GetMultiPlot()
+TEST_CASE("GetMultiPlot", "[MappingService]")
{
try
{
+ STRING m_session;
+ Ptr<MgServerSiteService> svcSite = TestServiceFactory::CreateSiteService();
+ Ptr<MgUserInformation> userInfo = TestServiceFactory::CreateSession(svcSite, m_session, L"Administrator", L"admin");
+ Ptr<MgMappingService> m_svcMapping = TestServiceFactory::CreateMappingService();
+ Ptr<MgSiteConnection> m_siteConnection = TestServiceFactory::CreateSiteConnection(svcSite, m_session);
+
// make a runtime map
Ptr<MgResourceIdentifier> mapRes1 = new MgResourceIdentifier(L"Library://UnitTests/Maps/Sheboygan.MapDefinition");
Ptr<MgMap> map1 = new MgMap(m_siteConnection);
@@ -681,7 +407,7 @@
INT64 len = eplot->GetLength();
- //CPPUNIT_ASSERT(len == 7000); // TODO: determine correct length
+ //REQUIRE(len == 7000); // TODO: determine correct length
//Ptr<MgByteSink> byteSink = new MgByteSink(eplot);
//byteSink->ToFile(L"UTNewMultiPlot.dwf");
@@ -688,9 +414,9 @@
}
catch (MgException* e)
{
- STRING message = e->GetDetails(TEST_LOCALE);
+ STRING message = e->GetDetails(TestServiceFactory::TEST_LOCALE);
SAFE_RELEASE(e);
- CPPUNIT_FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
+ FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
}
catch (...)
{
@@ -698,11 +424,16 @@
}
}
-
-void TestMappingService::TestCase_GetPlotUsingCurrentCenterAndScale()
+TEST_CASE("GetPlotUsingCurrentCenterAndScale", "[MappingService]")
{
try
{
+ STRING m_session;
+ Ptr<MgServerSiteService> svcSite = TestServiceFactory::CreateSiteService();
+ Ptr<MgUserInformation> userInfo = TestServiceFactory::CreateSession(svcSite, m_session, L"Administrator", L"admin");
+ Ptr<MgMappingService> m_svcMapping = TestServiceFactory::CreateMappingService();
+ Ptr<MgSiteConnection> m_siteConnection = TestServiceFactory::CreateSiteConnection(svcSite, m_session);
+
// make a runtime map
Ptr<MgResourceIdentifier> mapRes1 = new MgResourceIdentifier(L"Library://UnitTests/Maps/Sheboygan.MapDefinition");
Ptr<MgMap> map1 = new MgMap(m_siteConnection);
@@ -727,7 +458,7 @@
INT64 len = eplot->GetLength();
- // CPPUNIT_ASSERT(len == 7000); // TODO: determine correct length
+ // REQUIRE(len == 7000); // TODO: determine correct length
//Ptr<MgByteSink> byteSink = new MgByteSink(eplot);
//byteSink->ToFile(L"UTNewCurrentCentreAndScalePlot.dwf");
@@ -734,9 +465,9 @@
}
catch (MgException* e)
{
- STRING message = e->GetDetails(TEST_LOCALE);
+ STRING message = e->GetDetails(TestServiceFactory::TEST_LOCALE);
SAFE_RELEASE(e);
- CPPUNIT_FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
+ FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
}
catch (...)
{
@@ -744,11 +475,16 @@
}
}
-
-void TestMappingService::TestCase_GetPlotUsingOverriddenCenterAndScale()
+TEST_CASE("GetPlotUsingOverriddenCenterAndScale", "[MappingService]")
{
try
{
+ STRING m_session;
+ Ptr<MgServerSiteService> svcSite = TestServiceFactory::CreateSiteService();
+ Ptr<MgUserInformation> userInfo = TestServiceFactory::CreateSession(svcSite, m_session, L"Administrator", L"admin");
+ Ptr<MgMappingService> m_svcMapping = TestServiceFactory::CreateMappingService();
+ Ptr<MgSiteConnection> m_siteConnection = TestServiceFactory::CreateSiteConnection(svcSite, m_session);
+
// make a runtime map
Ptr<MgResourceIdentifier> mapRes1 = new MgResourceIdentifier(L"Library://UnitTests/Maps/Sheboygan.MapDefinition");
Ptr<MgMap> map1 = new MgMap(m_siteConnection);
@@ -772,7 +508,7 @@
INT64 len = eplot->GetLength();
- // CPPUNIT_ASSERT(len == 7000); // TODO: determine correct length
+ // REQUIRE(len == 7000); // TODO: determine correct length
//Ptr<MgByteSink> byteSink = new MgByteSink(eplot);
//byteSink->ToFile(L"UTNewOveriddenCenterAndScalePlot.dwf");
@@ -779,9 +515,9 @@
}
catch (MgException* e)
{
- STRING message = e->GetDetails(TEST_LOCALE);
+ STRING message = e->GetDetails(TestServiceFactory::TEST_LOCALE);
SAFE_RELEASE(e);
- CPPUNIT_FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
+ FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
}
catch (...)
{
@@ -789,11 +525,16 @@
}
}
-
-void TestMappingService::TestCase_GetPlotUsingExtents()
+TEST_CASE("GetPlotUsingExtents", "[MappingService]")
{
try
{
+ STRING m_session;
+ Ptr<MgServerSiteService> svcSite = TestServiceFactory::CreateSiteService();
+ Ptr<MgUserInformation> userInfo = TestServiceFactory::CreateSession(svcSite, m_session, L"Administrator", L"admin");
+ Ptr<MgMappingService> m_svcMapping = TestServiceFactory::CreateMappingService();
+ Ptr<MgSiteConnection> m_siteConnection = TestServiceFactory::CreateSiteConnection(svcSite, m_session);
+
// make a runtime map
Ptr<MgResourceIdentifier> mapRes1 = new MgResourceIdentifier(L"Library://UnitTests/Maps/Sheboygan.MapDefinition");
Ptr<MgMap> map1 = new MgMap(m_siteConnection);
@@ -817,7 +558,7 @@
INT64 len = eplot->GetLength();
- // CPPUNIT_ASSERT(len == 7000); // TODO: determine correct length
+ // REQUIRE(len == 7000); // TODO: determine correct length
//Ptr<MgByteSink> byteSink = new MgByteSink(eplot);
//byteSink->ToFile(L"UTNewExtentsPlot.dwf");
@@ -824,9 +565,9 @@
}
catch (MgException* e)
{
- STRING message = e->GetDetails(TEST_LOCALE);
+ STRING message = e->GetDetails(TestServiceFactory::TEST_LOCALE);
SAFE_RELEASE(e);
- CPPUNIT_FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
+ FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
}
catch (...)
{
@@ -834,11 +575,16 @@
}
}
-
-void TestMappingService::TestCase_GetPlotUsingExtentsAndExpandToFit()
+TEST_CASE("GetPlotUsingExtentsAndExpandToFit", "[MappingService]")
{
try
{
+ STRING m_session;
+ Ptr<MgServerSiteService> svcSite = TestServiceFactory::CreateSiteService();
+ Ptr<MgUserInformation> userInfo = TestServiceFactory::CreateSession(svcSite, m_session, L"Administrator", L"admin");
+ Ptr<MgMappingService> m_svcMapping = TestServiceFactory::CreateMappingService();
+ Ptr<MgSiteConnection> m_siteConnection = TestServiceFactory::CreateSiteConnection(svcSite, m_session);
+
// make a runtime map
Ptr<MgResourceIdentifier> mapRes1 = new MgResourceIdentifier(L"Library://UnitTests/Maps/Sheboygan.MapDefinition");
Ptr<MgMap> map1 = new MgMap(m_siteConnection);
@@ -862,7 +608,7 @@
INT64 len = eplot->GetLength();
- // CPPUNIT_ASSERT(len == 7000); // TODO: determine correct length
+ // REQUIRE(len == 7000); // TODO: determine correct length
//Ptr<MgByteSink> byteSink = new MgByteSink(eplot);
//byteSink->ToFile(L"UTNewExtentsExpandToFitPlot.dwf");
@@ -869,9 +615,9 @@
}
catch (MgException* e)
{
- STRING message = e->GetDetails(TEST_LOCALE);
+ STRING message = e->GetDetails(TestServiceFactory::TEST_LOCALE);
SAFE_RELEASE(e);
- CPPUNIT_FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
+ FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
}
catch (...)
{
@@ -879,11 +625,16 @@
}
}
-
-void TestMappingService::TestCase_GetLegendPlot()
+TEST_CASE("GetLegendPlot", "[MappingService]")
{
try
{
+ STRING m_session;
+ Ptr<MgServerSiteService> svcSite = TestServiceFactory::CreateSiteService();
+ Ptr<MgUserInformation> userInfo = TestServiceFactory::CreateSession(svcSite, m_session, L"Administrator", L"admin");
+ Ptr<MgMappingService> m_svcMapping = TestServiceFactory::CreateMappingService();
+ Ptr<MgSiteConnection> m_siteConnection = TestServiceFactory::CreateSiteConnection(svcSite, m_session);
+
// make a runtime map
Ptr<MgResourceIdentifier> mapRes1 = new MgResourceIdentifier(L"Library://UnitTests/Maps/Sheboygan.MapDefinition");
Ptr<MgMap> map1 = new MgMap(m_siteConnection);
@@ -900,7 +651,7 @@
INT64 len = eplot->GetLength();
- //CPPUNIT_ASSERT(len == 7000); // TODO: determine correct length
+ //REQUIRE(len == 7000); // TODO: determine correct length
//Ptr<MgByteSink> byteSink = new MgByteSink(eplot);
//byteSink->ToFile(L"UTNewLegendPlot.dwf");
@@ -907,9 +658,9 @@
}
catch (MgException* e)
{
- STRING message = e->GetDetails(TEST_LOCALE);
+ STRING message = e->GetDetails(TestServiceFactory::TEST_LOCALE);
SAFE_RELEASE(e);
- CPPUNIT_FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
+ FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
}
catch (...)
{
@@ -917,10 +668,16 @@
}
}
-void TestMappingService::TestCase_GetLegendImage()
+TEST_CASE("GetLegendImage", "[MappingService]")
{
try
{
+ STRING m_session;
+ Ptr<MgServerSiteService> svcSite = TestServiceFactory::CreateSiteService();
+ Ptr<MgUserInformation> userInfo = TestServiceFactory::CreateSession(svcSite, m_session, L"Administrator", L"admin");
+ Ptr<MgMappingService> m_svcMapping = TestServiceFactory::CreateMappingService();
+ Ptr<MgSiteConnection> m_siteConnection = TestServiceFactory::CreateSiteConnection(svcSite, m_session);
+
Ptr<MgResourceIdentifier> ldf = new MgResourceIdentifier(L"Library://UnitTests/Layers/Parcels.LayerDefinition");
Ptr<MgByteReader> rdr = m_svcMapping->GenerateLegendImage(ldf, 10000.0, 16, 16, MgImageFormats::Png, 3, 0);
Ptr<MgByteSink> sink = new MgByteSink(rdr);
@@ -940,9 +697,9 @@
}
catch (MgException* e)
{
- STRING message = e->GetDetails(TEST_LOCALE);
+ STRING message = e->GetDetails(TestServiceFactory::TEST_LOCALE);
SAFE_RELEASE(e);
- CPPUNIT_FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
+ FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
}
catch (...)
{
@@ -950,10 +707,16 @@
}
}
-void TestMappingService::TestCase_GetLegendImagePointStyleWithConstRotations()
+TEST_CASE("GetLegndImagePointStyleWithConstRotations", "[MappingService]")
{
try
{
+ STRING m_session;
+ Ptr<MgServerSiteService> svcSite = TestServiceFactory::CreateSiteService();
+ Ptr<MgUserInformation> userInfo = TestServiceFactory::CreateSession(svcSite, m_session, L"Administrator", L"admin");
+ Ptr<MgMappingService> m_svcMapping = TestServiceFactory::CreateMappingService();
+ Ptr<MgSiteConnection> m_siteConnection = TestServiceFactory::CreateSiteConnection(svcSite, m_session);
+
Ptr<MgResourceIdentifier> ldfId = new MgResourceIdentifier(L"Library://UnitTests/Layers/RotatedPointStyles.LayerDefinition");
//Do 16x16 icons first. Our common scenario.
@@ -1082,9 +845,9 @@
}
catch (MgException* e)
{
- STRING message = e->GetDetails(TEST_LOCALE);
+ STRING message = e->GetDetails(TestServiceFactory::TEST_LOCALE);
SAFE_RELEASE(e);
- CPPUNIT_FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
+ FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
}
catch (...)
{
@@ -1092,10 +855,17 @@
}
}
-void TestMappingService::TestCase_GetLegendImageConvenience()
+TEST_CASE("GetLegendImageConvenience", "[MappingService]")
{
try
{
+ STRING m_session;
+ Ptr<MgServerSiteService> svcSite = TestServiceFactory::CreateSiteService();
+ Ptr<MgUserInformation> userInfo = TestServiceFactory::CreateSession(svcSite, m_session, L"Administrator", L"admin");
+ Ptr<MgMappingService> m_svcMapping = TestServiceFactory::CreateMappingService();
+ Ptr<MgResourceService> m_svcResource = TestServiceFactory::CreateResourceService();
+ Ptr<MgSiteConnection> m_siteConnection = TestServiceFactory::CreateSiteConnection(svcSite, m_session);
+
Ptr<MgResourceIdentifier> mapres = new MgResourceIdentifier(L"Library://UnitTests/Maps/Sheboygan.MapDefinition");
Ptr<MgMap> map = new MgMap(m_siteConnection);
map->Create(mapres, L"TestCase_GetLegendImageConvenience");
@@ -1107,23 +877,23 @@
layers->Insert(0, layer);
Ptr<MgIntCollection> types = layer->GetGeometryTypeStyles(10000.0);
- CPPUNIT_ASSERT(1 == types->GetCount());
- CPPUNIT_ASSERT(types->IndexOf(1) < 0);
- CPPUNIT_ASSERT(types->IndexOf(2) < 0);
- CPPUNIT_ASSERT(types->IndexOf(3) >= 0);
- CPPUNIT_ASSERT(types->IndexOf(4) < 0);
+ REQUIRE(1 == types->GetCount());
+ REQUIRE(types->IndexOf(1) < 0);
+ REQUIRE(types->IndexOf(2) < 0);
+ REQUIRE(types->IndexOf(3) >= 0);
+ REQUIRE(types->IndexOf(4) < 0);
- CPPUNIT_ASSERT(8 == layer->GetThemeCategoryCount(10000.0, 3));
- CPPUNIT_ASSERT(-1 == layer->GetThemeCategoryCount(10000.0, 1));
- CPPUNIT_ASSERT(-1 == layer->GetThemeCategoryCount(10000.0, 2));
- CPPUNIT_ASSERT(-1 == layer->GetThemeCategoryCount(10000.0, 4));
+ REQUIRE(8 == layer->GetThemeCategoryCount(10000.0, 3));
+ REQUIRE(-1 == layer->GetThemeCategoryCount(10000.0, 1));
+ REQUIRE(-1 == layer->GetThemeCategoryCount(10000.0, 2));
+ REQUIRE(-1 == layer->GetThemeCategoryCount(10000.0, 4));
types = layer->GetGeometryTypeStyles(14000.0);
- CPPUNIT_ASSERT(NULL == types.p);
- CPPUNIT_ASSERT(-1 == layer->GetThemeCategoryCount(14000.0, 3));
- CPPUNIT_ASSERT(-1 == layer->GetThemeCategoryCount(14000.0, 1));
- CPPUNIT_ASSERT(-1 == layer->GetThemeCategoryCount(14000.0, 2));
- CPPUNIT_ASSERT(-1 == layer->GetThemeCategoryCount(14000.0, 4));
+ REQUIRE(NULL == types.p);
+ REQUIRE(-1 == layer->GetThemeCategoryCount(14000.0, 3));
+ REQUIRE(-1 == layer->GetThemeCategoryCount(14000.0, 1));
+ REQUIRE(-1 == layer->GetThemeCategoryCount(14000.0, 2));
+ REQUIRE(-1 == layer->GetThemeCategoryCount(14000.0, 4));
Ptr<MgByteReader> rdr = layer->GenerateLegendImage(10000.0, 16, 16, MgImageFormats::Png, 3, 0);
Ptr<MgByteSink> sink = new MgByteSink(rdr);
@@ -1143,9 +913,9 @@
}
catch (MgException* e)
{
- STRING message = e->GetDetails(TEST_LOCALE);
+ STRING message = e->GetDetails(TestServiceFactory::TEST_LOCALE);
SAFE_RELEASE(e);
- CPPUNIT_FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
+ FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
}
catch (...)
{
@@ -1153,10 +923,17 @@
}
}
-void TestMappingService::TestCase_GetLegendImageCompositeConvenience()
+TEST_CASE("GetLegendImageCompositeConvenience", "[MappingService]")
{
try
{
+ STRING m_session;
+ Ptr<MgServerSiteService> svcSite = TestServiceFactory::CreateSiteService();
+ Ptr<MgUserInformation> userInfo = TestServiceFactory::CreateSession(svcSite, m_session, L"Administrator", L"admin");
+ Ptr<MgMappingService> m_svcMapping = TestServiceFactory::CreateMappingService();
+ Ptr<MgResourceService> m_svcResource = TestServiceFactory::CreateResourceService();
+ Ptr<MgSiteConnection> m_siteConnection = TestServiceFactory::CreateSiteConnection(svcSite, m_session);
+
Ptr<MgResourceIdentifier> mapres = new MgResourceIdentifier(L"Library://UnitTests/Maps/Sheboygan.MapDefinition");
Ptr<MgMap> map = new MgMap(m_siteConnection);
map->Create(mapres, L"TestCase_GetLegendImageCompositeConvenience");
@@ -1168,24 +945,24 @@
layers->Insert(0, layer);
Ptr<MgIntCollection> types = layer->GetGeometryTypeStyles(10000.0);
- CPPUNIT_ASSERT(3 == types->GetCount());
- CPPUNIT_ASSERT(types->IndexOf(1) < 0);
- CPPUNIT_ASSERT(types->IndexOf(2) < 0);
- CPPUNIT_ASSERT(types->IndexOf(3) < 0);
- CPPUNIT_ASSERT(types->IndexOf(4) >= 0);
+ REQUIRE(3 == types->GetCount());
+ REQUIRE(types->IndexOf(1) < 0);
+ REQUIRE(types->IndexOf(2) < 0);
+ REQUIRE(types->IndexOf(3) < 0);
+ REQUIRE(types->IndexOf(4) >= 0);
for (INT32 i = 0; i < types->GetCount(); i++)
{
- CPPUNIT_ASSERT(4 == types->GetItem(i));
+ REQUIRE(4 == types->GetItem(i));
}
- CPPUNIT_ASSERT(-1 == layer->GetThemeCategoryCount(10000.0, 1));
- CPPUNIT_ASSERT(-1 == layer->GetThemeCategoryCount(10000.0, 2));
- CPPUNIT_ASSERT(-1 == layer->GetThemeCategoryCount(10000.0, 3));
- CPPUNIT_ASSERT(1 == layer->GetThemeCategoryCount(10000.0, 4));
- CPPUNIT_ASSERT(1 == layer->GetCompositeThemeCategoryCount(10000.0, 0));
- CPPUNIT_ASSERT(1 == layer->GetCompositeThemeCategoryCount(10000.0, 1));
- CPPUNIT_ASSERT(1 == layer->GetCompositeThemeCategoryCount(10000.0, 2));
- CPPUNIT_ASSERT(-1 == layer->GetCompositeThemeCategoryCount(10000.0, 3));
+ REQUIRE(-1 == layer->GetThemeCategoryCount(10000.0, 1));
+ REQUIRE(-1 == layer->GetThemeCategoryCount(10000.0, 2));
+ REQUIRE(-1 == layer->GetThemeCategoryCount(10000.0, 3));
+ REQUIRE(1 == layer->GetThemeCategoryCount(10000.0, 4));
+ REQUIRE(1 == layer->GetCompositeThemeCategoryCount(10000.0, 0));
+ REQUIRE(1 == layer->GetCompositeThemeCategoryCount(10000.0, 1));
+ REQUIRE(1 == layer->GetCompositeThemeCategoryCount(10000.0, 2));
+ REQUIRE(-1 == layer->GetCompositeThemeCategoryCount(10000.0, 3));
INT32 rulesProcessed = 0;
for (INT32 ctype = 0; ctype < 3; ctype++)
@@ -1230,9 +1007,9 @@
}
catch (MgException* e)
{
- STRING message = e->GetDetails(TEST_LOCALE);
+ STRING message = e->GetDetails(TestServiceFactory::TEST_LOCALE);
SAFE_RELEASE(e);
- CPPUNIT_FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
+ FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
}
catch (...)
{
@@ -1240,10 +1017,17 @@
}
}
-void TestMappingService::TestCase_GetLegendImageCompositeThemedConvenience()
+TEST_CASE("GetLegendImageCompositeThemedConvenience", "[MappingService]")
{
try
{
+ STRING m_session;
+ Ptr<MgServerSiteService> svcSite = TestServiceFactory::CreateSiteService();
+ Ptr<MgUserInformation> userInfo = TestServiceFactory::CreateSession(svcSite, m_session, L"Administrator", L"admin");
+ Ptr<MgMappingService> m_svcMapping = TestServiceFactory::CreateMappingService();
+ Ptr<MgResourceService> m_svcResource = TestServiceFactory::CreateResourceService();
+ Ptr<MgSiteConnection> m_siteConnection = TestServiceFactory::CreateSiteConnection(svcSite, m_session);
+
Ptr<MgResourceIdentifier> mapres = new MgResourceIdentifier(L"Library://UnitTests/Maps/Sheboygan.MapDefinition");
Ptr<MgMap> map = new MgMap(m_siteConnection);
map->Create(mapres, L"TestCase_GetLegendImageCompositeThemedConvenience");
@@ -1255,24 +1039,24 @@
layers->Insert(0, layer);
Ptr<MgIntCollection> types = layer->GetGeometryTypeStyles(10000.0);
- CPPUNIT_ASSERT(3 == types->GetCount());
- CPPUNIT_ASSERT(types->IndexOf(1) < 0);
- CPPUNIT_ASSERT(types->IndexOf(2) < 0);
- CPPUNIT_ASSERT(types->IndexOf(3) < 0);
- CPPUNIT_ASSERT(types->IndexOf(4) >= 0);
+ REQUIRE(3 == types->GetCount());
+ REQUIRE(types->IndexOf(1) < 0);
+ REQUIRE(types->IndexOf(2) < 0);
+ REQUIRE(types->IndexOf(3) < 0);
+ REQUIRE(types->IndexOf(4) >= 0);
for (INT32 i = 0; i < types->GetCount(); i++)
{
- CPPUNIT_ASSERT(4 == types->GetItem(i));
+ REQUIRE(4 == types->GetItem(i));
}
- CPPUNIT_ASSERT(-1 == layer->GetThemeCategoryCount(10000.0, 1));
- CPPUNIT_ASSERT(-1 == layer->GetThemeCategoryCount(10000.0, 2));
- CPPUNIT_ASSERT(-1 == layer->GetThemeCategoryCount(10000.0, 3));
- CPPUNIT_ASSERT(1 == layer->GetThemeCategoryCount(10000.0, 4));
- CPPUNIT_ASSERT(1 == layer->GetCompositeThemeCategoryCount(10000.0, 0));
- CPPUNIT_ASSERT(3 == layer->GetCompositeThemeCategoryCount(10000.0, 1));
- CPPUNIT_ASSERT(1 == layer->GetCompositeThemeCategoryCount(10000.0, 2));
- CPPUNIT_ASSERT(-1 == layer->GetCompositeThemeCategoryCount(10000.0, 3));
+ REQUIRE(-1 == layer->GetThemeCategoryCount(10000.0, 1));
+ REQUIRE(-1 == layer->GetThemeCategoryCount(10000.0, 2));
+ REQUIRE(-1 == layer->GetThemeCategoryCount(10000.0, 3));
+ REQUIRE(1 == layer->GetThemeCategoryCount(10000.0, 4));
+ REQUIRE(1 == layer->GetCompositeThemeCategoryCount(10000.0, 0));
+ REQUIRE(3 == layer->GetCompositeThemeCategoryCount(10000.0, 1));
+ REQUIRE(1 == layer->GetCompositeThemeCategoryCount(10000.0, 2));
+ REQUIRE(-1 == layer->GetCompositeThemeCategoryCount(10000.0, 3));
INT32 rulesProcessed = 0;
for (INT32 ctype = 0; ctype < 3; ctype++)
@@ -1318,9 +1102,9 @@
}
catch (MgException* e)
{
- STRING message = e->GetDetails(TEST_LOCALE);
+ STRING message = e->GetDetails(TestServiceFactory::TEST_LOCALE);
SAFE_RELEASE(e);
- CPPUNIT_FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
+ FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
}
catch (...)
{
@@ -1328,10 +1112,17 @@
}
}
-void TestMappingService::TestCase_GetLegendImagePointStyleWithConstRotationsConvenience()
+TEST_CASE("GetLegendImagePointStyleWithConstRotationConvenience", "[MappingService]")
{
try
{
+ STRING m_session;
+ Ptr<MgServerSiteService> svcSite = TestServiceFactory::CreateSiteService();
+ Ptr<MgUserInformation> userInfo = TestServiceFactory::CreateSession(svcSite, m_session, L"Administrator", L"admin");
+ Ptr<MgMappingService> m_svcMapping = TestServiceFactory::CreateMappingService();
+ Ptr<MgResourceService> m_svcResource = TestServiceFactory::CreateResourceService();
+ Ptr<MgSiteConnection> m_siteConnection = TestServiceFactory::CreateSiteConnection(svcSite, m_session);
+
Ptr<MgResourceIdentifier> mapres = new MgResourceIdentifier(L"Library://UnitTests/Maps/Sheboygan.MapDefinition");
Ptr<MgMap> map = new MgMap(m_siteConnection);
map->Create(mapres, L"TestCase_GetLegendImageConvenience");
@@ -1343,16 +1134,16 @@
layers->Insert(0, layer);
Ptr<MgIntCollection> types = layer->GetGeometryTypeStyles(1000.0);
- CPPUNIT_ASSERT(1 == types->GetCount());
- CPPUNIT_ASSERT(types->IndexOf(1) >= 0);
- CPPUNIT_ASSERT(types->IndexOf(2) < 0);
- CPPUNIT_ASSERT(types->IndexOf(3) < 0);
- CPPUNIT_ASSERT(types->IndexOf(4) < 0);
+ REQUIRE(1 == types->GetCount());
+ REQUIRE(types->IndexOf(1) >= 0);
+ REQUIRE(types->IndexOf(2) < 0);
+ REQUIRE(types->IndexOf(3) < 0);
+ REQUIRE(types->IndexOf(4) < 0);
- CPPUNIT_ASSERT(15 == layer->GetThemeCategoryCount(1000.0, 1));
- CPPUNIT_ASSERT(-1 == layer->GetThemeCategoryCount(1000.0, 2));
- CPPUNIT_ASSERT(-1 == layer->GetThemeCategoryCount(1000.0, 3));
- CPPUNIT_ASSERT(-1 == layer->GetThemeCategoryCount(1000.0, 4));
+ REQUIRE(15 == layer->GetThemeCategoryCount(1000.0, 1));
+ REQUIRE(-1 == layer->GetThemeCategoryCount(1000.0, 2));
+ REQUIRE(-1 == layer->GetThemeCategoryCount(1000.0, 3));
+ REQUIRE(-1 == layer->GetThemeCategoryCount(1000.0, 4));
//Do 16x16 icons first. Our common scenario.
@@ -1480,9 +1271,9 @@
}
catch (MgException* e)
{
- STRING message = e->GetDetails(TEST_LOCALE);
+ STRING message = e->GetDetails(TestServiceFactory::TEST_LOCALE);
SAFE_RELEASE(e);
- CPPUNIT_FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
+ FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
}
catch (...)
{
@@ -1490,10 +1281,18 @@
}
}
-void TestMappingService::TestCase_QueryFeaturesImageMap()
+//TEST_CASE("QueryFeaturesImageMap", "[MappingService]")
+void TestCase_QueryFeaturesImageMap()
{
try
{
+ STRING m_session;
+ Ptr<MgServerSiteService> svcSite = TestServiceFactory::CreateSiteService();
+ Ptr<MgUserInformation> userInfo = TestServiceFactory::CreateSession(svcSite, m_session, L"Administrator", L"admin");
+ Ptr<MgMappingService> m_svcMapping = TestServiceFactory::CreateMappingService();
+ Ptr<MgResourceService> m_svcResource = TestServiceFactory::CreateResourceService();
+ Ptr<MgSiteConnection> m_siteConnection = TestServiceFactory::CreateSiteConnection(svcSite, m_session);
+
// make a runtime map
Ptr<MgResourceIdentifier> mdfres = new MgResourceIdentifier(L"Library://UnitTests/Maps/Sheboygan.MapDefinition");
Ptr<MgMap> map = new MgMap(m_siteConnection);
@@ -1524,9 +1323,9 @@
}
catch (MgException* e)
{
- STRING message = e->GetDetails(TEST_LOCALE);
+ STRING message = e->GetDetails(TestServiceFactory::TEST_LOCALE);
SAFE_RELEASE(e);
- CPPUNIT_FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
+ FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
}
catch (...)
{
@@ -1534,10 +1333,16 @@
}
}
-void TestMappingService::TestCase_PlotMultiPolygonWithHoles()
+TEST_CASE("PlotMultiPolygonWithHoles", "[MappingService]")
{
try
{
+ STRING m_session;
+ Ptr<MgServerSiteService> svcSite = TestServiceFactory::CreateSiteService();
+ Ptr<MgUserInformation> userInfo = TestServiceFactory::CreateSession(svcSite, m_session, L"Administrator", L"admin");
+ Ptr<MgMappingService> m_svcMapping = TestServiceFactory::CreateMappingService();
+ Ptr<MgSiteConnection> m_siteConnection = TestServiceFactory::CreateSiteConnection(svcSite, m_session);
+
// make a runtime map
Ptr<MgResourceIdentifier> mapRes1 = new MgResourceIdentifier(L"Library://UnitTests/PlotHole/Maps/Test.MapDefinition");
Ptr<MgMap> map1 = new MgMap(m_siteConnection);
@@ -1562,7 +1367,7 @@
INT64 len = eplot->GetLength();
- // CPPUNIT_ASSERT(len == 7000); // TODO: determine correct length
+ // REQUIRE(len == 7000); // TODO: determine correct length
// Have to manually verify this file atm. There should be no fill in the hole
Ptr<MgByteSink> byteSink = new MgByteSink(eplot);
@@ -1570,9 +1375,9 @@
}
catch (MgException* e)
{
- STRING message = e->GetDetails(TEST_LOCALE);
+ STRING message = e->GetDetails(TestServiceFactory::TEST_LOCALE);
SAFE_RELEASE(e);
- CPPUNIT_FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
+ FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
}
catch (...)
{
Deleted: sandbox/jng/catch2/Server/src/UnitTesting/TestMappingService.h
===================================================================
--- sandbox/jng/catch2/Server/src/UnitTesting/TestMappingService.h 2020-07-07 15:57:41 UTC (rev 9656)
+++ sandbox/jng/catch2/Server/src/UnitTesting/TestMappingService.h 2020-07-08 11:10:16 UTC (rev 9657)
@@ -1,96 +0,0 @@
-//
-// 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 TESTMAPPINGSERVICE_H_
-#define TESTMAPPINGSERVICE_H_
-
-#include <cppunit/extensions/HelperMacros.h>
-
-class TestMappingService : public CppUnit::TestFixture
-{
- CPPUNIT_TEST_SUITE(TestMappingService);
- CPPUNIT_TEST(TestStart); // This must be the very first unit test
-
- CPPUNIT_TEST(TestCase_SaveMap);
- CPPUNIT_TEST(TestCase_GetMultiPlot);
- CPPUNIT_TEST(TestCase_GetPlotUsingCurrentCenterAndScale);
- CPPUNIT_TEST(TestCase_GetPlotUsingOverriddenCenterAndScale);
- CPPUNIT_TEST(TestCase_GetPlotUsingExtents);
- CPPUNIT_TEST(TestCase_GetPlotUsingExtentsAndExpandToFit);
- CPPUNIT_TEST(TestCase_PlotMultiPolygonWithHoles);
- CPPUNIT_TEST(TestCase_GetLegendPlot);
- CPPUNIT_TEST(TestCase_GetLegendImage);
- CPPUNIT_TEST(TestCase_GetLegendImagePointStyleWithConstRotations);
- CPPUNIT_TEST(TestCase_GetLegendImageConvenience);
- CPPUNIT_TEST(TestCase_GetLegendImageCompositeConvenience);
- CPPUNIT_TEST(TestCase_GetLegendImageCompositeThemedConvenience);
- CPPUNIT_TEST(TestCase_GetLegendImagePointStyleWithConstRotationsConvenience);
- CPPUNIT_TEST(TestCase_CreateRuntimeMap260);
- CPPUNIT_TEST(TestCase_CreateRuntimeMap300);
- CPPUNIT_TEST(TestCase_CreateRuntimeMap400);
- CPPUNIT_TEST(TestCase_DescribeRuntimeMap);
- CPPUNIT_TEST(TestCase_CreateAndDescribeLinkedRuntimeMap);
- //CPPUNIT_TEST(TestCase_QueryFeaturesImageMap);
-
- CPPUNIT_TEST(TestEnd); // This must be the very last unit test
- CPPUNIT_TEST_SUITE_END();
-
-public:
-
- TestMappingService();
- ~TestMappingService();
-
- void setUp();
- void tearDown();
- void TestStart();
- void TestEnd();
-
- void TestCase_CreateRuntimeMap(INT32 major, INT32 minor, INT32 rev);
- void TestCase_CreateRuntimeMap260() { TestCase_CreateRuntimeMap(2, 6, 0); }
- void TestCase_CreateRuntimeMap300() { TestCase_CreateRuntimeMap(3, 0, 0); }
- void TestCase_CreateRuntimeMap400() { TestCase_CreateRuntimeMap(4, 0, 0); }
- void TestCase_DescribeRuntimeMap();
- void TestCase_SaveMap();
- void TestCase_GetPlot();
- void TestCase_GetMultiPlot();
- void TestCase_CreateAndDescribeLinkedRuntimeMap();
- void TestCase_GetPlotUsingCurrentCenterAndScale();
- void TestCase_GetPlotUsingOverriddenCenterAndScale();
- void TestCase_GetPlotUsingExtents();
- void TestCase_GetPlotUsingExtentsAndExpandToFit();
- void TestCase_PlotMultiPolygonWithHoles();
- void TestCase_GetLegendPlot();
- void TestCase_GetLegendImage();
- void TestCase_GetLegendImagePointStyleWithConstRotations();
- void TestCase_GetLegendImageConvenience();
- void TestCase_GetLegendImageCompositeConvenience();
- void TestCase_GetLegendImageCompositeThemedConvenience();
- void TestCase_GetLegendImagePointStyleWithConstRotationsConvenience();
- void TestCase_QueryFeaturesImageMap();
-
-private:
-
- void PublishTheResources();
-
- Ptr<MgSiteConnection> m_siteConnection;
- Ptr<MgResourceService> m_svcResource;
- Ptr<MgMappingService> m_svcMapping;
-
- STRING m_session;
-};
-
-#endif // TESTMAPPINGSERVICE_H_
Modified: sandbox/jng/catch2/Server/src/UnitTesting/UnitTesting.vcxproj
===================================================================
--- sandbox/jng/catch2/Server/src/UnitTesting/UnitTesting.vcxproj 2020-07-07 15:57:41 UTC (rev 9656)
+++ sandbox/jng/catch2/Server/src/UnitTesting/UnitTesting.vcxproj 2020-07-08 11:10:16 UTC (rev 9657)
@@ -202,12 +202,8 @@
<ClInclude Include="CppUnitExtensions.h" />
<ClInclude Include="TestServiceFactory.h" />
<ClInclude Include="TestCoordinateSystem.h" />
- <ClInclude Include="TestDrawingService.h" />
<ClInclude Include="TestFeatureService.h" />
- <ClInclude Include="TestKmlService.h" />
- <ClInclude Include="TestLogManager.h" />
<ClInclude Include="TestLogManagerThread.h" />
- <ClInclude Include="TestMappingService.h" />
<ClInclude Include="TestPerformance.h" />
<ClInclude Include="TestProfilingService.h" />
<ClInclude Include="TestRenderingService.h" />
More information about the mapguide-commits
mailing list