[asterisk-scf-commits] asterisk-scf/release/logger.git branch "master" updated.
Commits to the Asterisk SCF project code repositories
asterisk-scf-commits at lists.digium.com
Thu Apr 21 17:06:40 CDT 2011
branch "master" has been updated
via fa95cc2a32a973556640d845f407854ae0e386e3 (commit)
via 56a0e97d36418f9a7d64e3171c265355b146350f (commit)
via 8efccfb68d50b6de54e9936b0b2c05836a2f29ec (commit)
via 6d6db8f75151dc286cb05283fb4dbc3717598d0a (commit)
via 7fad057cd987478e5b66c376febc4ac8b5437037 (commit)
via 12c8fe7c473a36d690054c7c6d81571990b63cc1 (commit)
via 484f42421c3e0de5da362a42109ae8c5ccc49db8 (commit)
via 356e1ce8ebfe6b996a7a82f45497a0cbcc6f263a (commit)
via 154937cf74e4613a5bac1eaec33ce96bd0790af8 (commit)
via 0c7312212a76b9397e5f741cc2ed797191fbce31 (commit)
via fed994c745cb81e08fdceb7f4cae2fcf5dfc1a05 (commit)
via f0b98e570b459ae5861d9541b2c2c4b2ff6b41ff (commit)
via 87c1fcce07101a99f599bfe8ad0bb6a4aa360b02 (commit)
via 299462b725655f8c2f57c05149e7e2deb59bbd5d (commit)
via 90cdfbef42ca87e8c336ab54f6f02819d36ffb43 (commit)
via b2631be10abdb630e7f053c4aa2987006250bde7 (commit)
via 89913e2ec673202c8ad86138f77cbd51ec4304b8 (commit)
via df11e7299041cb14c0e7e6ae16bacab26684ee4e (commit)
via f96891fc9c304d2eb9c9a164a3d6384b711bb268 (commit)
via 99b842b1a4246af6d9a994dfcd038945af45ba3d (commit)
via 7a21a63526f7d87c5b406e5982eee034d0e64088 (commit)
via db0541d2be19e8315654a7a93eb2e9965ea72834 (commit)
via a6199b7aeeddffc9808bee7677dda3bab2f722a6 (commit)
via 7dc0dcea1e006aa36b58018cb5ca6775430c5a68 (commit)
via 3647c1bbdbc25f25d3d4c1cd866944977f25601e (commit)
via 004bf0ed5de341a3a3212fb21b5d1987fbb3e2ea (commit)
via 2416bede77f0052f3fb2e3e1bccbdc0b725bba9d (commit)
via 1ce571cc146ef90318b769d7c712fe51ddc744d6 (commit)
from f72807265551350b1046235d1ef1bac5a4129d0f (commit)
Summary of changes:
server/CMakeLists.txt | 1 +
{client => server/config}/CMakeLists.txt | 2 +-
server/config/testloggingserver.conf.in | 11 +
server/local-slice/LoggingConfigurationIf.ice | 79 ++++++
server/src/CMakeLists.txt | 8 +-
server/src/Configuration.cpp | 366 +++++++++++++++++++++++++
server/src/Configuration.h | 66 +++++
server/src/FileChainedLogOut.h | 9 +
server/src/LoggingServer.cpp | 32 ++-
server/src/LoggingServer.h | 12 +-
server/src/OstreamChainedLogOut.h | 5 +
server/src/main.cpp | 20 +-
server/test/CMakeLists.txt | 19 ++-
server/test/ConfigurationTest.cpp | 236 ++++++++++++++++
server/test/LoggingConfigurationHelper.cpp | 111 ++++++++
server/test/LoggingConfigurationHelper.h | 33 +++
slice | 2 +-
17 files changed, 992 insertions(+), 20 deletions(-)
copy {client => server/config}/CMakeLists.txt (63%)
create mode 100644 server/config/testloggingserver.conf.in
create mode 100644 server/local-slice/LoggingConfigurationIf.ice
create mode 100644 server/src/Configuration.cpp
create mode 100644 server/src/Configuration.h
create mode 100644 server/test/ConfigurationTest.cpp
create mode 100644 server/test/LoggingConfigurationHelper.cpp
create mode 100644 server/test/LoggingConfigurationHelper.h
- Log -----------------------------------------------------------------
commit fa95cc2a32a973556640d845f407854ae0e386e3
Author: Mark Michelson <mmichelson at digium.com>
Date: Thu Apr 21 17:03:12 2011 -0500
Make sure reference operators are next to types instead of parameter names.
diff --git a/server/src/Configuration.cpp b/server/src/Configuration.cpp
index cbefec7..09efb98 100644
--- a/server/src/Configuration.cpp
+++ b/server/src/Configuration.cpp
@@ -32,7 +32,7 @@ using namespace AsteriskSCF::System::Logger::V1;
class FileItemI : public FileItem
{
public:
- FileItemI(const LoggingServerIPtr &server, const std::string &file)
+ FileItemI(const LoggingServerIPtr& server, const std::string& file)
: mServer(server), mOut(new FileChainedLogOut(file))
{
fileName = file;
@@ -51,7 +51,7 @@ typedef IceUtil::Handle<FileItemI> FileItemIPtr;
class LoggerGeneralConfiguration : public IceUtil::Shared
{
public:
- LoggerGeneralConfiguration(const LoggerGeneralGroupPtr &group)
+ LoggerGeneralConfiguration(const LoggerGeneralGroupPtr& group)
: mGroup(group) { }
FileItemIPtr mOutputFile;
LoggerGeneralGroupPtr mGroup;
@@ -78,7 +78,7 @@ ConfigurationGroupSeq LoggerConfigurationService::getConfiguration(const Configu
class LoggerGroupVisitor : public LoggerConfigurationGroupVisitor
{
public:
- LoggerGroupVisitor(const ConfigurationServicePrivPtr &priv, ConfigurationGroupSeq &visitorGroups)
+ LoggerGroupVisitor(const ConfigurationServicePrivPtr& priv, ConfigurationGroupSeq& visitorGroups)
: mPriv(priv), mGroups(visitorGroups) { }
private:
/**
@@ -104,7 +104,7 @@ ConfigurationGroupSeq LoggerConfigurationService::getConfiguration(const Configu
}
}
- void visitLoggerGeneralGroup(const LoggerGeneralGroupPtr &group)
+ void visitLoggerGeneralGroup(const LoggerGeneralGroupPtr& group)
{
if (!mPriv->mGeneralConfiguration)
{
@@ -117,7 +117,7 @@ ConfigurationGroupSeq LoggerConfigurationService::getConfiguration(const Configu
}
ConfigurationServicePrivPtr mPriv;
- ConfigurationGroupSeq &mGroups;
+ ConfigurationGroupSeq& mGroups;
};
ConfigurationGroupSeq newGroups;
@@ -136,10 +136,10 @@ ConfigurationGroupSeq LoggerConfigurationService::getConfigurationAll(const Conf
class LoggerGroupVisitor : public LoggerConfigurationGroupVisitor
{
public:
- LoggerGroupVisitor(const ConfigurationServicePrivPtr &priv, ConfigurationGroupSeq &visitorGroups)
+ LoggerGroupVisitor(const ConfigurationServicePrivPtr& priv, ConfigurationGroupSeq& visitorGroups)
: mPriv(priv), mGroups(visitorGroups) { }
private:
- void visitLoggerGeneralGroup(const LoggerGeneralGroupPtr &group)
+ void visitLoggerGeneralGroup(const LoggerGeneralGroupPtr&)
{
if (!mPriv->mGeneralConfiguration)
{
@@ -150,7 +150,7 @@ ConfigurationGroupSeq LoggerConfigurationService::getConfigurationAll(const Conf
}
ConfigurationServicePrivPtr mPriv;
- ConfigurationGroupSeq &mGroups;
+ ConfigurationGroupSeq& mGroups;
};
ConfigurationGroupSeq newGroups;
@@ -182,13 +182,13 @@ void LoggerConfigurationService::setConfiguration(const ConfigurationGroupSeq& g
class GroupsVisitor : public LoggerConfigurationGroupVisitor
{
public:
- GroupsVisitor(const ConfigurationServicePrivPtr &priv)
+ GroupsVisitor(const ConfigurationServicePrivPtr& priv)
: mPriv(priv) { }
private:
/**
* Helper function which performs serial number checking of items
*/
- void performSerialCheck(const ConfigurationItemDict& changedItems, const ConfigurationGroupPtr &localGroup)
+ void performSerialCheck(const ConfigurationItemDict& changedItems, const ConfigurationGroupPtr& localGroup)
{
for (ConfigurationItemDict::const_iterator item = changedItems.begin();
item != changedItems.end();
@@ -215,7 +215,7 @@ void LoggerConfigurationService::setConfiguration(const ConfigurationGroupSeq& g
}
}
- void visitLoggerGeneralGroup(const LoggerGeneralGroupPtr &group)
+ void visitLoggerGeneralGroup(const LoggerGeneralGroupPtr& group)
{
if (!mPriv->mGeneralConfiguration)
{
@@ -232,7 +232,7 @@ void LoggerConfigurationService::setConfiguration(const ConfigurationGroupSeq& g
GeneralItemsVisitor(ConfigurationServicePrivPtr priv)
: mPriv(priv) { }
private:
- void visitFileItem(const FileItemPtr &fileItem)
+ void visitFileItem(const FileItemPtr& fileItem)
{
if (mPriv->mGeneralConfiguration->mOutputFile &&
mPriv->mGeneralConfiguration->mOutputFile->fileName == fileItem->fileName)
@@ -274,7 +274,7 @@ void LoggerConfigurationService::removeConfigurationItems(const ConfigurationGro
class GroupsVisitor : public LoggerConfigurationGroupVisitor
{
public:
- GroupsVisitor(const ConfigurationServicePrivPtr &priv)
+ GroupsVisitor(const ConfigurationServicePrivPtr& priv)
: mPriv(priv) { }
private:
@@ -298,7 +298,7 @@ void LoggerConfigurationService::removeConfigurationItems(const ConfigurationGro
}
}
- void visitLoggerGeneralGroup(const LoggerGeneralGroupPtr &group)
+ void visitLoggerGeneralGroup(const LoggerGeneralGroupPtr& group)
{
if (!mPriv->mGeneralConfiguration)
{
@@ -308,10 +308,10 @@ void LoggerConfigurationService::removeConfigurationItems(const ConfigurationGro
class GeneralItemsVisitor : public LoggerConfigurationItemVisitor
{
public:
- GeneralItemsVisitor(const LoggerGeneralConfigurationPtr &generalGroup)
+ GeneralItemsVisitor(const LoggerGeneralConfigurationPtr& generalGroup)
: mGroup(generalGroup) { }
private:
- void visitFileItem(const FileItemPtr &fileItem)
+ void visitFileItem(const FileItemPtr& fileItem)
{
if (mGroup->mOutputFile && mGroup->mOutputFile->fileName == fileItem->fileName)
{
@@ -341,10 +341,10 @@ void LoggerConfigurationService::removeConfigurationGroups(const ConfigurationGr
class LoggerGroupVisitor : public LoggerConfigurationGroupVisitor
{
public:
- LoggerGroupVisitor(const ConfigurationServicePrivPtr &priv)
+ LoggerGroupVisitor(const ConfigurationServicePrivPtr& priv)
: mPriv(priv) { }
private:
- void visitLoggerGeneralGroup(const LoggerGeneralGroupPtr &group)
+ void visitLoggerGeneralGroup(const LoggerGeneralGroupPtr&)
{
mPriv->mGeneralConfiguration = 0;
}
commit 56a0e97d36418f9a7d64e3171c265355b146350f
Merge: f728072 8efccfb
Author: Mark Michelson <mmichelson at digium.com>
Date: Thu Apr 21 17:00:13 2011 -0500
Merge branch 'filename'
commit 8efccfb68d50b6de54e9936b0b2c05836a2f29ec
Author: Mark Michelson <mmichelson at digium.com>
Date: Thu Apr 21 16:57:03 2011 -0500
Fix problems found while attempting to run tests on windows.
This is now ready for mergification
diff --git a/server/config/testloggingserver.conf.in b/server/config/testloggingserver.conf.in
index fa00404..985e254 100644
--- a/server/config/testloggingserver.conf.in
+++ b/server/config/testloggingserver.conf.in
@@ -1,7 +1,7 @@
IceBox.InheritProperties = 1
IceBox.Service.Logger =../src at logging-service:createLoggingService
-IceBox.Service.LoggerTest = ../test at ConfigurationTest:create
+IceBox.Service.LoggerTest = ../test at LoggingConfigurationTest:create
IceBox.LoadOrder=Logger,LoggerTest
diff --git a/server/test/ConfigurationTest.cpp b/server/test/ConfigurationTest.cpp
index bee1a48..fd11742 100644
--- a/server/test/ConfigurationTest.cpp
+++ b/server/test/ConfigurationTest.cpp
@@ -229,7 +229,7 @@ BOOST_AUTO_TEST_CASE(PurposefulSerialConflict)
extern "C"
{
-IceBox::Service* create(Ice::CommunicatorPtr communicator)
+ASTERISK_SCF_ICEBOX_EXPORT IceBox::Service* create(Ice::CommunicatorPtr communicator)
{
return new LoggerConfigurationTest;
}
commit 6d6db8f75151dc286cb05283fb4dbc3717598d0a
Author: Mark Michelson <mmichelson at digium.com>
Date: Thu Apr 21 13:32:11 2011 -0500
Forgot to add this file earlier.
diff --git a/server/config/CMakeLists.txt b/server/config/CMakeLists.txt
new file mode 100644
index 0000000..2497637
--- /dev/null
+++ b/server/config/CMakeLists.txt
@@ -0,0 +1,9 @@
+#
+# Asterisk Scalable Communications Framework
+#
+# Copyright (C) 2010 -- Digium, Inc.
+#
+# All rights reserved.
+#
+
+configure_file(testloggingserver.conf.in testloggingserver.conf)
commit 7fad057cd987478e5b66c376febc4ac8b5437037
Author: Mark Michelson <mmichelson at digium.com>
Date: Wed Apr 20 16:55:53 2011 -0500
Change name of the test from ConfigurationTest to LoggerConfigurationTest.
This makes it so when running make test, it's more clear what's being tested.
diff --git a/server/test/CMakeLists.txt b/server/test/CMakeLists.txt
index cba065c..01fd304 100644
--- a/server/test/CMakeLists.txt
+++ b/server/test/CMakeLists.txt
@@ -26,17 +26,17 @@ target_link_libraries(logging-service-test logging-service-lib)
boost_add_test(logging-service-test)
-asterisk_scf_component_init(ConfigurationTest CXX)
+asterisk_scf_component_init(LoggingConfigurationTest CXX)
-asterisk_scf_component_add_file(ConfigurationTest ConfigurationTest.cpp)
-asterisk_scf_component_add_file(ConfigurationTest LoggingConfigurationHelper.cpp)
-asterisk_scf_component_add_file(ConfigurationTest LoggingConfigurationHelper.h)
-asterisk_scf_component_add_slice(ConfigurationTest ../local-slice/LoggingConfigurationIf.ice)
-asterisk_scf_component_add_boost_libraries(ConfigurationTest unit_test_framework)
+asterisk_scf_component_add_file(LoggingConfigurationTest ConfigurationTest.cpp)
+asterisk_scf_component_add_file(LoggingConfigurationTest LoggingConfigurationHelper.cpp)
+asterisk_scf_component_add_file(LoggingConfigurationTest LoggingConfigurationHelper.h)
+asterisk_scf_component_add_slice(LoggingConfigurationTest ../local-slice/LoggingConfigurationIf.ice)
+asterisk_scf_component_add_boost_libraries(LoggingConfigurationTest unit_test_framework)
include_directories(${API_INCLUDE_DIR})
-asterisk_scf_component_build_icebox(ConfigurationTest)
-target_link_libraries(ConfigurationTest asterisk-scf-api)
+asterisk_scf_component_build_icebox(LoggingConfigurationTest)
+target_link_libraries(LoggingConfigurationTest asterisk-scf-api)
if(integrated_build STREQUAL "true")
- icebox_add_test(ConfigurationTest ../config/testloggingserver.conf)
+ icebox_add_test(LoggingConfigurationTest ../config/testloggingserver.conf)
endif()
commit 12c8fe7c473a36d690054c7c6d81571990b63cc1
Author: Mark Michelson <mmichelson at digium.com>
Date: Wed Apr 20 16:47:37 2011 -0500
Add a line I must have deleted so the logging-server test is added to the test suite.
diff --git a/server/test/CMakeLists.txt b/server/test/CMakeLists.txt
index 6f1e89f..cba065c 100644
--- a/server/test/CMakeLists.txt
+++ b/server/test/CMakeLists.txt
@@ -24,6 +24,8 @@ target_link_libraries(logging-service-test asterisk-scf-api)
target_link_libraries(logging-service-test logging-service-lib)
+boost_add_test(logging-service-test)
+
asterisk_scf_component_init(ConfigurationTest CXX)
asterisk_scf_component_add_file(ConfigurationTest ConfigurationTest.cpp)
commit 484f42421c3e0de5da362a42109ae8c5ccc49db8
Author: Mark Michelson <mmichelson at digium.com>
Date: Wed Apr 20 15:18:48 2011 -0500
Get Configuration tests passing.
Some highlights:
1. Fixed shadow violation warnings in configuration code.
2. Fixed error where FileItemI did not set its file name.
3. Fixed error where a visitor was declared on the stack instead of the heap.
4. Added config file so that test starts properly
5. Fixed error where trying to replace a configured file name would only halfway work.
With these changes, I've noticed the logging server test doesn't seem to run any more
when I run 'make test' in the build directory. I imagine I've messed with something
in the config that's causing that to occur, so I'll need to figure out what's up there.
diff --git a/server/CMakeLists.txt b/server/CMakeLists.txt
index 6b2ef65..61e6803 100644
--- a/server/CMakeLists.txt
+++ b/server/CMakeLists.txt
@@ -8,3 +8,4 @@
add_subdirectory(src)
add_subdirectory(test)
+add_subdirectory(config)
diff --git a/server/config/testloggingserver.conf b/server/config/testloggingserver.conf.in
similarity index 55%
rename from server/config/testloggingserver.conf
rename to server/config/testloggingserver.conf.in
index 3515d74..fa00404 100644
--- a/server/config/testloggingserver.conf
+++ b/server/config/testloggingserver.conf.in
@@ -1,8 +1,11 @@
IceBox.InheritProperties = 1
IceBox.Service.Logger =../src at logging-service:createLoggingService
-IceBox.Service.LoggerTest = LoggerTest:create
+IceBox.Service.LoggerTest = ../test at ConfigurationTest:create
+
+IceBox.LoadOrder=Logger,LoggerTest
AsteriskSCF.LoggingService.Endpoints = tcp -p 31337
+Logger.Proxy=LoggerConfigurationService:tcp -p 31337
LoggerTestAdapter.Endpoints = default
diff --git a/server/src/Configuration.cpp b/server/src/Configuration.cpp
index cf70445..cbefec7 100644
--- a/server/src/Configuration.cpp
+++ b/server/src/Configuration.cpp
@@ -32,9 +32,10 @@ using namespace AsteriskSCF::System::Logger::V1;
class FileItemI : public FileItem
{
public:
- FileItemI(const LoggingServerIPtr &server, const std::string &fileName)
- : mServer(server), mOut(new FileChainedLogOut(fileName))
+ FileItemI(const LoggingServerIPtr &server, const std::string &file)
+ : mServer(server), mOut(new FileChainedLogOut(file))
{
+ fileName = file;
mServer->addLogOut(mOut);
}
~FileItemI()
@@ -45,9 +46,9 @@ public:
boost::shared_ptr<ChainedLogOut> mOut;
};
-typedef boost::shared_ptr<FileItemI> FileItemIPtr;
+typedef IceUtil::Handle<FileItemI> FileItemIPtr;
-class LoggerGeneralConfiguration
+class LoggerGeneralConfiguration : public IceUtil::Shared
{
public:
LoggerGeneralConfiguration(const LoggerGeneralGroupPtr &group)
@@ -56,7 +57,7 @@ public:
LoggerGeneralGroupPtr mGroup;
};
-typedef boost::shared_ptr<LoggerGeneralConfiguration> LoggerGeneralConfigurationPtr;
+typedef IceUtil::Handle<LoggerGeneralConfiguration> LoggerGeneralConfigurationPtr;
class ConfigurationServicePriv
{
@@ -77,8 +78,8 @@ ConfigurationGroupSeq LoggerConfigurationService::getConfiguration(const Configu
class LoggerGroupVisitor : public LoggerConfigurationGroupVisitor
{
public:
- LoggerGroupVisitor(const ConfigurationServicePrivPtr &priv, ConfigurationGroupSeq &groups)
- : mPriv(priv), mGroups(groups) { }
+ LoggerGroupVisitor(const ConfigurationServicePrivPtr &priv, ConfigurationGroupSeq &visitorGroups)
+ : mPriv(priv), mGroups(visitorGroups) { }
private:
/**
* Internal helper function which determines what configuration items should be returned
@@ -99,7 +100,7 @@ ConfigurationGroupSeq LoggerConfigurationService::getConfiguration(const Configu
continue;
}
- returnedItems.insert(*requestedItem);
+ returnedItems.insert(*localItem);
}
}
@@ -135,8 +136,8 @@ ConfigurationGroupSeq LoggerConfigurationService::getConfigurationAll(const Conf
class LoggerGroupVisitor : public LoggerConfigurationGroupVisitor
{
public:
- LoggerGroupVisitor(const ConfigurationServicePrivPtr &priv, ConfigurationGroupSeq &groups)
- : mPriv(priv), mGroups(groups) { }
+ LoggerGroupVisitor(const ConfigurationServicePrivPtr &priv, ConfigurationGroupSeq &visitorGroups)
+ : mPriv(priv), mGroups(visitorGroups) { }
private:
void visitLoggerGeneralGroup(const LoggerGeneralGroupPtr &group)
{
@@ -218,7 +219,7 @@ void LoggerConfigurationService::setConfiguration(const ConfigurationGroupSeq& g
{
if (!mPriv->mGeneralConfiguration)
{
- mPriv->mGeneralConfiguration.reset(new LoggerGeneralConfiguration(new LoggerGeneralGroup));
+ mPriv->mGeneralConfiguration = new LoggerGeneralConfiguration(new LoggerGeneralGroup);
}
else
{
@@ -241,7 +242,7 @@ void LoggerConfigurationService::setConfiguration(const ConfigurationGroupSeq& g
return;
}
- mPriv->mGeneralConfiguration->mOutputFile.reset(new FileItemI(mPriv->mServer, fileItem->fileName));
+ mPriv->mGeneralConfiguration->mOutputFile = new FileItemI(mPriv->mServer, fileItem->fileName);
}
ConfigurationServicePrivPtr mPriv;
};
@@ -252,6 +253,7 @@ void LoggerConfigurationService::setConfiguration(const ConfigurationGroupSeq& g
item != group->configurationItems.end();
++item)
{
+ mPriv->mGeneralConfiguration->mGroup->configurationItems.erase(item->first);
mPriv->mGeneralConfiguration->mGroup->configurationItems.insert(*item);
item->second->visit(generalVisitor);
}
@@ -268,6 +270,7 @@ void LoggerConfigurationService::setConfiguration(const ConfigurationGroupSeq& g
void LoggerConfigurationService::removeConfigurationItems(const ConfigurationGroupSeq& groups, const Ice::Current&)
{
+
class GroupsVisitor : public LoggerConfigurationGroupVisitor
{
public:
@@ -275,7 +278,7 @@ void LoggerConfigurationService::removeConfigurationItems(const ConfigurationGro
: mPriv(priv) { }
private:
- void removeItems(LoggerConfigurationItemVisitor* visitor, const ConfigurationItemDict& itemsToRemove,
+ void removeItems(LoggerConfigurationItemVisitorPtr visitor, const ConfigurationItemDict& itemsToRemove,
ConfigurationItemDict& localItems)
{
for (ConfigurationItemDict::const_iterator item = itemsToRemove.begin();
@@ -305,20 +308,22 @@ void LoggerConfigurationService::removeConfigurationItems(const ConfigurationGro
class GeneralItemsVisitor : public LoggerConfigurationItemVisitor
{
public:
- GeneralItemsVisitor(const LoggerGeneralConfigurationPtr &group)
- : mGroup(group) { }
+ GeneralItemsVisitor(const LoggerGeneralConfigurationPtr &generalGroup)
+ : mGroup(generalGroup) { }
private:
void visitFileItem(const FileItemPtr &fileItem)
{
if (mGroup->mOutputFile && mGroup->mOutputFile->fileName == fileItem->fileName)
{
- mGroup->mOutputFile.reset();
+ mGroup->mOutputFile = 0;
}
}
LoggerGeneralConfigurationPtr mGroup;
- } generalVisitor(mPriv->mGeneralConfiguration);
+ };
+
+ LoggerConfigurationItemVisitorPtr generalVisitor(new GeneralItemsVisitor(mPriv->mGeneralConfiguration));
- removeItems(&generalVisitor, group->configurationItems, mPriv->mGeneralConfiguration->mGroup->configurationItems);
+ removeItems(generalVisitor, group->configurationItems, mPriv->mGeneralConfiguration->mGroup->configurationItems);
}
ConfigurationServicePrivPtr mPriv;
};
@@ -341,7 +346,7 @@ void LoggerConfigurationService::removeConfigurationGroups(const ConfigurationGr
private:
void visitLoggerGeneralGroup(const LoggerGeneralGroupPtr &group)
{
- mPriv->mGeneralConfiguration.reset();
+ mPriv->mGeneralConfiguration = 0;
}
ConfigurationServicePrivPtr mPriv;
};
diff --git a/server/test/CMakeLists.txt b/server/test/CMakeLists.txt
index 37d60fc..6f1e89f 100644
--- a/server/test/CMakeLists.txt
+++ b/server/test/CMakeLists.txt
@@ -27,8 +27,8 @@ target_link_libraries(logging-service-test logging-service-lib)
asterisk_scf_component_init(ConfigurationTest CXX)
asterisk_scf_component_add_file(ConfigurationTest ConfigurationTest.cpp)
-asterisk_scf_component_add_file(ConfigurationTest ConfigurationComponent.cpp)
-asterisk_scf_component_add_file(ConfigurationTest ConfigurationComponent.h)
+asterisk_scf_component_add_file(ConfigurationTest LoggingConfigurationHelper.cpp)
+asterisk_scf_component_add_file(ConfigurationTest LoggingConfigurationHelper.h)
asterisk_scf_component_add_slice(ConfigurationTest ../local-slice/LoggingConfigurationIf.ice)
asterisk_scf_component_add_boost_libraries(ConfigurationTest unit_test_framework)
include_directories(${API_INCLUDE_DIR})
diff --git a/server/test/ConfigurationTest.cpp b/server/test/ConfigurationTest.cpp
index b94cb3b..bee1a48 100644
--- a/server/test/ConfigurationTest.cpp
+++ b/server/test/ConfigurationTest.cpp
@@ -26,7 +26,7 @@
#include <AsteriskSCF/System/Component/ConfigurationIf.h>
-#include "ConfigurationComponent.h"
+#include "LoggingConfigurationHelper.h"
using namespace AsteriskSCF::System::Configuration::V1;
using namespace AsteriskSCF::System::Logger::V1;
@@ -61,6 +61,7 @@ public:
mCachedArgs.argc = argv.size() - 1;
mCachedArgs.argv = (char**)&argv[0];
+ mCachedArgs.inheritedProps = communicator->getProperties();
int r = ::boost::unit_test::unit_test_main(&init_unit_test, mCachedArgs.argc, mCachedArgs.argv);
exit(r);
@@ -94,8 +95,11 @@ struct GlobalIceFixture
TestBed.communicator = Ice::initialize(initData);
TestBed.adapter = TestBed.communicator->createObjectAdapterWithEndpoints("LoggerTestAdapter", "default");
- Ice::ObjectPrx loggerObj = TestBed.communicator->propertyToProxy("LoggerServer.Proxy");
- TestBed.confHelper.reset(new LoggingConfigurationHelper(ConfigurationServicePrx::checkedCast(loggerObj)));
+ Ice::PropertiesPtr communicatorProps = TestBed.communicator->getProperties();
+ std::string proxyProp = communicatorProps->getProperty("Logger.Proxy");
+ Ice::ObjectPrx loggerObj = TestBed.communicator->stringToProxy(proxyProp);
+ ConfigurationServicePrx confPrx = ConfigurationServicePrx::checkedCast(loggerObj);
+ TestBed.confHelper.reset(new LoggingConfigurationHelper(confPrx));
}
catch (const Ice::Exception &ex)
{
@@ -146,6 +150,7 @@ static FileStatus checkConfiguredFile(const boost::shared_ptr<LoggingConfigurati
// none of the other tests will work.
BOOST_AUTO_TEST_CASE(SetAndRemoveFile)
{
+ BOOST_TEST_MESSAGE("TEST");
const std::string fileName("zombiebrains.txt");
try
{
diff --git a/server/test/LoggingConfigurationHelper.cpp b/server/test/LoggingConfigurationHelper.cpp
index 4757f17..52dceba 100644
--- a/server/test/LoggingConfigurationHelper.cpp
+++ b/server/test/LoggingConfigurationHelper.cpp
@@ -18,7 +18,7 @@
* This is a component that pushes test data to the logging server.
*/
-#include "ConfigurationComponent.h"
+#include "LoggingConfigurationHelper.h"
#include "LoggingConfigurationIf.h"
namespace
@@ -58,7 +58,6 @@ void LoggingConfigurationHelper::removeLogOutFile(const std::string &fileName)
AsteriskSCF::System::Logger::V1::FileItemPtr LoggingConfigurationHelper::getConfiguredOutputFile()
{
//Part 1: Retrieval from the configuration service.
-
ConfigurationGroupSeq queryGroups;
LoggerGeneralGroupPtr generalGroup(new LoggerGeneralGroup);
FileItemPtr file(new FileItem);
commit 356e1ce8ebfe6b996a7a82f45497a0cbcc6f263a
Author: Mark Michelson <mmichelson at digium.com>
Date: Thu Mar 31 15:02:14 2011 -0500
Add documentation of the FileItem.
diff --git a/server/local-slice/LoggingConfigurationIf.ice b/server/local-slice/LoggingConfigurationIf.ice
index 231bd2f..964c61f 100644
--- a/server/local-slice/LoggingConfigurationIf.ice
+++ b/server/local-slice/LoggingConfigurationIf.ice
@@ -62,8 +62,14 @@ module V1
{
};
+ /**
+ * ConfigurationItem that describes an output file to which logger output should be sent
+ */
class FileItem extends LoggerConfigurationItem
{
+ /**
+ * The name of the file to send output to
+ */
string fileName;
};
commit 154937cf74e4613a5bac1eaec33ce96bd0790af8
Author: Mark Michelson <mmichelson at digium.com>
Date: Thu Mar 31 14:58:45 2011 -0500
Make changes suggested by reviewers:
* Update copyright dates to 2011
* Change "visitor" class to be "LoggingGroupVisitor"
* Change file name of ConfigurationComponent.* in the tests to LoggingConfigurationHelper.*
* s/Impl/Priv/g in source
diff --git a/server/src/CMakeLists.txt b/server/src/CMakeLists.txt
index 5d02911..a2859bb 100644
--- a/server/src/CMakeLists.txt
+++ b/server/src/CMakeLists.txt
@@ -1,7 +1,7 @@
#
# Asterisk Scalable Communications Framework
#
-# Copyright (C) 2010 -- Digium, Inc.
+# Copyright (C) 2011 -- Digium, Inc.
#
# All rights reserved.
#
diff --git a/server/src/Configuration.cpp b/server/src/Configuration.cpp
index a17a2e4..cf70445 100644
--- a/server/src/Configuration.cpp
+++ b/server/src/Configuration.cpp
@@ -58,27 +58,27 @@ public:
typedef boost::shared_ptr<LoggerGeneralConfiguration> LoggerGeneralConfigurationPtr;
-class ConfigurationServiceImpl
+class ConfigurationServicePriv
{
public:
- ConfigurationServiceImpl(LoggingServerIPtr server)
+ ConfigurationServicePriv(LoggingServerIPtr server)
: mServer(server) { }
LoggingServerIPtr mServer;
LoggerGeneralConfigurationPtr mGeneralConfiguration;
};
-typedef boost::shared_ptr<ConfigurationServiceImpl> ConfigurationServiceImplPtr;
+typedef boost::shared_ptr<ConfigurationServicePriv> ConfigurationServicePrivPtr;
LoggerConfigurationService::LoggerConfigurationService(LoggingServerIPtr server)
- : mImpl(new ConfigurationServiceImpl(server)) { }
+ : mPriv(new ConfigurationServicePriv(server)) { }
ConfigurationGroupSeq LoggerConfigurationService::getConfiguration(const ConfigurationGroupSeq& groups, const Ice::Current&)
{
- class visitor : public LoggerConfigurationGroupVisitor
+ class LoggerGroupVisitor : public LoggerConfigurationGroupVisitor
{
public:
- visitor(const ConfigurationServiceImplPtr &impl, ConfigurationGroupSeq &groups)
- : mImpl(impl), mGroups(groups) { }
+ LoggerGroupVisitor(const ConfigurationServicePrivPtr &priv, ConfigurationGroupSeq &groups)
+ : mPriv(priv), mGroups(groups) { }
private:
/**
* Internal helper function which determines what configuration items should be returned
@@ -99,28 +99,28 @@ ConfigurationGroupSeq LoggerConfigurationService::getConfiguration(const Configu
continue;
}
- returnedItems.insert(make_pair((*requestedItem).first, (*requestedItem).second));
+ returnedItems.insert(*requestedItem);
}
}
void visitLoggerGeneralGroup(const LoggerGeneralGroupPtr &group)
{
- if (!mImpl->mGeneralConfiguration)
+ if (!mPriv->mGeneralConfiguration)
{
return;
}
LoggerGeneralGroupPtr returnedGroup = new LoggerGeneralGroup();
- insertRequestedConfigurationItems(group->configurationItems, mImpl->mGeneralConfiguration->mGroup->configurationItems, returnedGroup->configurationItems);
+ insertRequestedConfigurationItems(group->configurationItems, mPriv->mGeneralConfiguration->mGroup->configurationItems, returnedGroup->configurationItems);
mGroups.push_back(returnedGroup);
}
- ConfigurationServiceImplPtr mImpl;
+ ConfigurationServicePrivPtr mPriv;
ConfigurationGroupSeq &mGroups;
};
ConfigurationGroupSeq newGroups;
- LoggerConfigurationGroupVisitorPtr v = new visitor(mImpl, newGroups);
+ LoggerConfigurationGroupVisitorPtr v = new LoggerGroupVisitor(mPriv, newGroups);
for (ConfigurationGroupSeq::const_iterator group = groups.begin(); group != groups.end(); ++group)
{
@@ -132,28 +132,28 @@ ConfigurationGroupSeq LoggerConfigurationService::getConfiguration(const Configu
ConfigurationGroupSeq LoggerConfigurationService::getConfigurationAll(const ConfigurationGroupSeq& groups, const Ice::Current&)
{
- class visitor : public LoggerConfigurationGroupVisitor
+ class LoggerGroupVisitor : public LoggerConfigurationGroupVisitor
{
public:
- visitor(const ConfigurationServiceImplPtr &impl, ConfigurationGroupSeq &groups)
- : mImpl(impl), mGroups(groups) { }
+ LoggerGroupVisitor(const ConfigurationServicePrivPtr &priv, ConfigurationGroupSeq &groups)
+ : mPriv(priv), mGroups(groups) { }
private:
void visitLoggerGeneralGroup(const LoggerGeneralGroupPtr &group)
{
- if (!mImpl->mGeneralConfiguration)
+ if (!mPriv->mGeneralConfiguration)
{
return;
}
- mGroups.push_back(mImpl->mGeneralConfiguration->mGroup);
+ mGroups.push_back(mPriv->mGeneralConfiguration->mGroup);
}
- ConfigurationServiceImplPtr mImpl;
+ ConfigurationServicePrivPtr mPriv;
ConfigurationGroupSeq &mGroups;
};
ConfigurationGroupSeq newGroups;
- LoggerConfigurationGroupVisitorPtr v = new visitor(mImpl, newGroups);
+ LoggerConfigurationGroupVisitorPtr v = new LoggerGroupVisitor(mPriv, newGroups);
for (ConfigurationGroupSeq::const_iterator group = groups.begin(); group != groups.end(); ++group)
{
@@ -167,7 +167,7 @@ ConfigurationGroupSeq LoggerConfigurationService::getConfigurationGroups(const I
{
ConfigurationGroupSeq groups;
- if (mImpl->mGeneralConfiguration)
+ if (mPriv->mGeneralConfiguration)
{
LoggerGeneralGroupPtr general = new LoggerGeneralGroup();
groups.push_back(general);
@@ -181,8 +181,8 @@ void LoggerConfigurationService::setConfiguration(const ConfigurationGroupSeq& g
class GroupsVisitor : public LoggerConfigurationGroupVisitor
{
public:
- GroupsVisitor(const ConfigurationServiceImplPtr &impl)
- : mImpl(impl) { }
+ GroupsVisitor(const ConfigurationServicePrivPtr &priv)
+ : mPriv(priv) { }
private:
/**
* Helper function which performs serial number checking of items
@@ -216,49 +216,49 @@ void LoggerConfigurationService::setConfiguration(const ConfigurationGroupSeq& g
void visitLoggerGeneralGroup(const LoggerGeneralGroupPtr &group)
{
- if (!mImpl->mGeneralConfiguration)
+ if (!mPriv->mGeneralConfiguration)
{
- mImpl->mGeneralConfiguration.reset(new LoggerGeneralConfiguration(new LoggerGeneralGroup));
+ mPriv->mGeneralConfiguration.reset(new LoggerGeneralConfiguration(new LoggerGeneralGroup));
}
else
{
- performSerialCheck(group->configurationItems, mImpl->mGeneralConfiguration->mGroup);
+ performSerialCheck(group->configurationItems, mPriv->mGeneralConfiguration->mGroup);
}
class GeneralItemsVisitor : public LoggerConfigurationItemVisitor
{
public:
- GeneralItemsVisitor(ConfigurationServiceImplPtr impl)
- : mImpl(impl) { }
+ GeneralItemsVisitor(ConfigurationServicePrivPtr priv)
+ : mPriv(priv) { }
private:
void visitFileItem(const FileItemPtr &fileItem)
{
- if (mImpl->mGeneralConfiguration->mOutputFile &&
- mImpl->mGeneralConfiguration->mOutputFile->fileName == fileItem->fileName)
+ if (mPriv->mGeneralConfiguration->mOutputFile &&
+ mPriv->mGeneralConfiguration->mOutputFile->fileName == fileItem->fileName)
{
// The new configuration has the same file name as
// the old. Don't interrupt things. Just return.
return;
}
- mImpl->mGeneralConfiguration->mOutputFile.reset(new FileItemI(mImpl->mServer, fileItem->fileName));
+ mPriv->mGeneralConfiguration->mOutputFile.reset(new FileItemI(mPriv->mServer, fileItem->fileName));
}
- ConfigurationServiceImplPtr mImpl;
+ ConfigurationServicePrivPtr mPriv;
};
- LoggerConfigurationItemVisitorPtr generalVisitor = new GeneralItemsVisitor(mImpl);
+ LoggerConfigurationItemVisitorPtr generalVisitor = new GeneralItemsVisitor(mPriv);
for (ConfigurationItemDict::const_iterator item = group->configurationItems.begin();
item != group->configurationItems.end();
++item)
{
- mImpl->mGeneralConfiguration->mGroup->configurationItems.insert(make_pair(item->first, item->second));
+ mPriv->mGeneralConfiguration->mGroup->configurationItems.insert(*item);
item->second->visit(generalVisitor);
}
}
- ConfigurationServiceImplPtr mImpl;
+ ConfigurationServicePrivPtr mPriv;
};
- LoggerConfigurationGroupVisitorPtr v = new GroupsVisitor(mImpl);
+ LoggerConfigurationGroupVisitorPtr v = new GroupsVisitor(mPriv);
for (ConfigurationGroupSeq::const_iterator group = groups.begin(); group != groups.end(); ++group)
{
@@ -271,8 +271,8 @@ void LoggerConfigurationService::removeConfigurationItems(const ConfigurationGro
class GroupsVisitor : public LoggerConfigurationGroupVisitor
{
public:
- GroupsVisitor(const ConfigurationServiceImplPtr &impl)
- : mImpl(impl) { }
+ GroupsVisitor(const ConfigurationServicePrivPtr &priv)
+ : mPriv(priv) { }
private:
void removeItems(LoggerConfigurationItemVisitor* visitor, const ConfigurationItemDict& itemsToRemove,
@@ -297,7 +297,7 @@ void LoggerConfigurationService::removeConfigurationItems(const ConfigurationGro
void visitLoggerGeneralGroup(const LoggerGeneralGroupPtr &group)
{
- if (!mImpl->mGeneralConfiguration)
+ if (!mPriv->mGeneralConfiguration)
{
return;
}
@@ -316,14 +316,14 @@ void LoggerConfigurationService::removeConfigurationItems(const ConfigurationGro
}
}
LoggerGeneralConfigurationPtr mGroup;
- } generalVisitor(mImpl->mGeneralConfiguration);
+ } generalVisitor(mPriv->mGeneralConfiguration);
- removeItems(&generalVisitor, group->configurationItems, mImpl->mGeneralConfiguration->mGroup->configurationItems);
+ removeItems(&generalVisitor, group->configurationItems, mPriv->mGeneralConfiguration->mGroup->configurationItems);
}
- ConfigurationServiceImplPtr mImpl;
+ ConfigurationServicePrivPtr mPriv;
};
- LoggerConfigurationGroupVisitorPtr v = new GroupsVisitor(mImpl);
+ LoggerConfigurationGroupVisitorPtr v = new GroupsVisitor(mPriv);
for (ConfigurationGroupSeq::const_iterator group = groups.begin(); group != groups.end(); ++group)
{
@@ -333,20 +333,20 @@ void LoggerConfigurationService::removeConfigurationItems(const ConfigurationGro
void LoggerConfigurationService::removeConfigurationGroups(const ConfigurationGroupSeq& groups, const Ice::Current&)
{
- class visitor : public LoggerConfigurationGroupVisitor
+ class LoggerGroupVisitor : public LoggerConfigurationGroupVisitor
{
public:
- visitor(const ConfigurationServiceImplPtr &impl)
- : mImpl(impl) { }
+ LoggerGroupVisitor(const ConfigurationServicePrivPtr &priv)
+ : mPriv(priv) { }
private:
void visitLoggerGeneralGroup(const LoggerGeneralGroupPtr &group)
{
- mImpl->mGeneralConfiguration.reset();
+ mPriv->mGeneralConfiguration.reset();
}
- ConfigurationServiceImplPtr mImpl;
+ ConfigurationServicePrivPtr mPriv;
};
- LoggerConfigurationGroupVisitorPtr v = new visitor(mImpl);
+ LoggerConfigurationGroupVisitorPtr v = new LoggerGroupVisitor(mPriv);
for (ConfigurationGroupSeq::const_iterator group = groups.begin(); group != groups.end(); ++group)
{
diff --git a/server/src/Configuration.h b/server/src/Configuration.h
index 64125a9..fa5563d 100644
--- a/server/src/Configuration.h
+++ b/server/src/Configuration.h
@@ -37,10 +37,10 @@ namespace Logging
/*
* Private implementation class for ConfigurationService.
*/
-class ConfigurationServiceImpl;
+class ConfigurationServicePriv;
/**
- * Implementation of the configuration service.
+ * Privementation of the configuration service.
*/
class LoggerConfigurationService : public AsteriskSCF::System::Configuration::V1::ConfigurationService
{
@@ -56,7 +56,7 @@ private:
/**
* Private implementation details.
*/
- boost::shared_ptr<ConfigurationServiceImpl> mImpl;
+ boost::shared_ptr<ConfigurationServicePriv> mPriv;
};
}; //End namespace Logging
diff --git a/server/src/LoggingServer.cpp b/server/src/LoggingServer.cpp
index 764a236..5433884 100644
--- a/server/src/LoggingServer.cpp
+++ b/server/src/LoggingServer.cpp
@@ -1,7 +1,7 @@
/*
* Asterisk SCF -- An open-source communications framework.
*
- * Copyright (C) 2010, Digium, Inc.
+ * Copyright (C) 2011, Digium, Inc.
*
* See http://www.asterisk.org for more information about
* the Asterisk SCF project. Please do not directly contact
diff --git a/server/src/LoggingServer.h b/server/src/LoggingServer.h
index 5d6f3b0..3d68d71 100644
--- a/server/src/LoggingServer.h
+++ b/server/src/LoggingServer.h
@@ -1,7 +1,7 @@
/*
* Asterisk SCF -- An open-source communications framework.
*
- * Copyright (C) 2010, Digium, Inc.
+ * Copyright (C) 2011, Digium, Inc.
*
* See http://www.asterisk.org for more information about
* the Asterisk SCF project. Please do not directly contact
diff --git a/server/test/CMakeLists.txt b/server/test/CMakeLists.txt
index 41d2cc4..37d60fc 100644
--- a/server/test/CMakeLists.txt
+++ b/server/test/CMakeLists.txt
@@ -1,7 +1,7 @@
#
# Asterisk Scalable Communications Framework
#
-# Copyright (C) 2010 -- Digium, Inc.
+# Copyright (C) 2011 -- Digium, Inc.
#
# All rights reserved.
#
diff --git a/server/test/ConfigurationTest.cpp b/server/test/ConfigurationTest.cpp
index e4c9a07..b94cb3b 100644
--- a/server/test/ConfigurationTest.cpp
+++ b/server/test/ConfigurationTest.cpp
@@ -1,7 +1,7 @@
/*
* Asterisk SCF -- An open-source communications framework.
*
- * Copyright (C) 2010, Digium, Inc.
+ * Copyright (C) 2011, Digium, Inc.
*
* See http://www.asterisk.org for more information about
* the Asterisk SCF project. Please do not directly contact
diff --git a/server/test/ConfigurationComponent.cpp b/server/test/LoggingConfigurationHelper.cpp
similarity index 100%
rename from server/test/ConfigurationComponent.cpp
rename to server/test/LoggingConfigurationHelper.cpp
diff --git a/server/test/ConfigurationComponent.h b/server/test/LoggingConfigurationHelper.h
similarity index 100%
rename from server/test/ConfigurationComponent.h
rename to server/test/LoggingConfigurationHelper.h
diff --git a/slice b/slice
index 0c62939..03ea08a 160000
--- a/slice
+++ b/slice
@@ -1 +1 @@
-Subproject commit 0c629393e2f05dc0ed43bcc6305880949df36289
+Subproject commit 03ea08a0f749b5f36ae4dc36d25493689f9e273c
commit 0c7312212a76b9397e5f741cc2ed797191fbce31
Author: Mark Michelson <mmichelson at digium.com>
Date: Mon Mar 21 10:55:32 2011 -0500
Fix problems pointed out by Brent during code review.
diff --git a/server/src/Configuration.cpp b/server/src/Configuration.cpp
index 34685c8..a17a2e4 100644
--- a/server/src/Configuration.cpp
+++ b/server/src/Configuration.cpp
@@ -50,7 +50,7 @@ typedef boost::shared_ptr<FileItemI> FileItemIPtr;
class LoggerGeneralConfiguration
{
public:
- LoggerGeneralConfiguration(LoggerGeneralGroupPtr group)
+ LoggerGeneralConfiguration(const LoggerGeneralGroupPtr &group)
: mGroup(group) { }
FileItemIPtr mOutputFile;
LoggerGeneralGroupPtr mGroup;
@@ -83,12 +83,12 @@ ConfigurationGroupSeq LoggerConfigurationService::getConfiguration(const Configu
/**
* Internal helper function which determines what configuration items should be returned
*/
- void insertRequestedConfigurationItems(ConfigurationItemDict& requestedItems,
+ void insertRequestedConfigurationItems(const ConfigurationItemDict& requestedItems,
ConfigurationItemDict& localItems,
ConfigurationItemDict& returnedItems)
{
- for (ConfigurationItemDict::iterator requestedItem = requestedItems.begin();
+ for (ConfigurationItemDict::const_iterator requestedItem = requestedItems.begin();
requestedItem != requestedItems.end();
++requestedItem)
{
diff --git a/server/test/ConfigurationComponent.cpp b/server/test/ConfigurationComponent.cpp
index 5a09832..4757f17 100644
--- a/server/test/ConfigurationComponent.cpp
+++ b/server/test/ConfigurationComponent.cpp
@@ -40,6 +40,7 @@ void LoggingConfigurationHelper::setLogOutFile(const std::string &fileName, int
fileItem->fileName = fileName;
fileItem->serialNumber = serialNumber;
generalGroup->configurationItems.insert(make_pair(FileItemName, fileItem));
+ groups.push_back(generalGroup);
mConfigPrx->setConfiguration(groups);
}
@@ -50,6 +51,7 @@ void LoggingConfigurationHelper::removeLogOutFile(const std::string &fileName)
FileItemPtr fileItem(new FileItem);
fileItem->fileName = fileName;
generalGroup->configurationItems.insert(make_pair(FileItemName, fileItem));
+ groups.push_back(generalGroup);
mConfigPrx->removeConfigurationItems(groups);
}
commit fed994c745cb81e08fdceb7f4cae2fcf5dfc1a05
Author: Mark Michelson <mmichelson at digium.com>
Date: Tue Mar 15 18:26:38 2011 -0500
Add the test configuration file.
diff --git a/server/config/testloggingserver.conf b/server/config/testloggingserver.conf
new file mode 100644
index 0000000..3515d74
--- /dev/null
+++ b/server/config/testloggingserver.conf
@@ -0,0 +1,8 @@
+IceBox.InheritProperties = 1
+
+IceBox.Service.Logger =../src at logging-service:createLoggingService
+IceBox.Service.LoggerTest = LoggerTest:create
+
+AsteriskSCF.LoggingService.Endpoints = tcp -p 31337
+
+LoggerTestAdapter.Endpoints = default
commit f0b98e570b459ae5861d9541b2c2c4b2ff6b41ff
Author: Mark Michelson <mmichelson at digium.com>
Date: Tue Mar 15 17:44:13 2011 -0500
Add tests for when we expect no file to be configured.
diff --git a/server/test/ConfigurationTest.cpp b/server/test/ConfigurationTest.cpp
index 736c76a..e4c9a07 100644
--- a/server/test/ConfigurationTest.cpp
+++ b/server/test/ConfigurationTest.cpp
@@ -119,15 +119,26 @@ BOOST_GLOBAL_FIXTURE(GlobalIceFixture);
static int serial = 100;
-static bool checkConfiguredFile(const boost::shared_ptr<LoggingConfigurationHelper> &confHelper,
+enum FileStatus
+{
+ CORRECT,
+ INCORRECT,
+ NONEXISTENT
+};
+
+static FileStatus checkConfiguredFile(const boost::shared_ptr<LoggingConfigurationHelper> &confHelper,
const std::string &fileName)
{
FileItemPtr configuredFile = confHelper->getConfiguredOutputFile();
+ if (!configuredFile)
+ {
+ return NONEXISTENT;
+ }
if (configuredFile->fileName == fileName)
{
- return true;
+ return CORRECT;
}
- return false;
+ return INCORRECT;
}
// Basic test that sets a logging file to use and then
@@ -144,9 +155,13 @@ BOOST_AUTO_TEST_CASE(SetAndRemoveFile)
{
BOOST_FAIL("SerialConflict thrown when setting output file");
}
- checkConfiguredFile(TestBed.confHelper, fileName);
+ FileStatus status = checkConfiguredFile(TestBed.confHelper, fileName);
+ BOOST_CHECK(status == CORRECT);
TestBed.confHelper->removeLogOutFile(fileName);
- //There should be no configured output files.
+ //Whenever we expect the return to be NONEXISTENT, the filename we
+ //pass in really doesn't matter.
+ status = checkConfiguredFile(TestBed.confHelper, fileName);
+ BOOST_CHECK(status == NONEXISTENT);
}
BOOST_AUTO_TEST_CASE(FileReplacement)
@@ -156,26 +171,27 @@ BOOST_AUTO_TEST_CASE(FileReplacement)
try
{
TestBed.confHelper->setLogOutFile(fileName1, serial++);
- bool correct = checkConfiguredFile(TestBed.confHelper, fileName1);
- BOOST_CHECK(correct);
+ FileStatus status = checkConfiguredFile(TestBed.confHelper, fileName1);
+ BOOST_CHECK(status == CORRECT);
TestBed.confHelper->setLogOutFile(fileName2, serial++);
+ status = checkConfiguredFile(TestBed.confHelper, fileName2);
+ BOOST_CHECK(status == CORRECT);
}
catch (const SerialConflict &sc)
{
BOOST_FAIL("SerialConflict thrown when setting output file");
}
- bool correct = checkConfiguredFile(TestBed.confHelper, fileName2);
- BOOST_CHECK(correct);
TestBed.confHelper->removeLogOutFile(fileName2);
- //There should be no configured output files.
+ FileStatus status = checkConfiguredFile(TestBed.confHelper, fileName2);
+ BOOST_CHECK(status == NONEXISTENT);
}
BOOST_AUTO_TEST_CASE(NonexistentRemoval)
{
const std::string fileName("frankensteinspleens.txt");
TestBed.confHelper->removeLogOutFile(fileName);
- //There should be no configured output files, and
- //nothing catastrophic should have occurred.
+ FileStatus status = checkConfiguredFile(TestBed.confHelper, fileName);
+ BOOST_CHECK(status == NONEXISTENT);
}
BOOST_AUTO_TEST_CASE(PurposefulSerialConflict)
@@ -190,18 +206,20 @@ BOOST_AUTO_TEST_CASE(PurposefulSerialConflict)
{
BOOST_FAIL("SerialConflict thrown when setting output file");
}
- bool correct = checkConfiguredFile(TestBed.confHelper, fileName1);
- BOOST_CHECK(correct);
+ FileStatus status = checkConfiguredFile(TestBed.confHelper, fileName1);
+ BOOST_CHECK(status == CORRECT);
+ bool exceptionHit = false;
try
{
TestBed.confHelper->setLogOutFile(fileName2, serial++);
}
catch (const SerialConflict &ex)
{
- // We should hit this.
+ exceptionHit = true;
}
- correct = checkConfiguredFile(TestBed.confHelper, fileName1);
- BOOST_CHECK(correct);
+ BOOST_CHECK(exceptionHit == true);
+ status = checkConfiguredFile(TestBed.confHelper, fileName1);
+ BOOST_CHECK(status == CORRECT);
}
extern "C"
commit 87c1fcce07101a99f599bfe8ad0bb6a4aa360b02
Author: Mark Michelson <mmichelson at digium.com>
Date: Tue Mar 15 17:32:46 2011 -0500
Make sure to add test to the suite.
diff --git a/server/test/CMakeLists.txt b/server/test/CMakeLists.txt
index 49486fc..41d2cc4 100644
--- a/server/test/CMakeLists.txt
+++ b/server/test/CMakeLists.txt
@@ -35,4 +35,6 @@ include_directories(${API_INCLUDE_DIR})
asterisk_scf_component_build_icebox(ConfigurationTest)
target_link_libraries(ConfigurationTest asterisk-scf-api)
-boost_add_test(logging-service-test)
+if(integrated_build STREQUAL "true")
+ icebox_add_test(ConfigurationTest ../config/testloggingserver.conf)
+endif()
commit 299462b725655f8c2f57c05149e7e2deb59bbd5d
Author: Mark Michelson <mmichelson at digium.com>
Date: Tue Mar 15 17:12:17 2011 -0500
Add some testing for correctness after setting configuration.
I just need to add something similar for making sure nothing is there
and I'll be SET.
diff --git a/server/test/ConfigurationComponent.cpp b/server/test/ConfigurationComponent.cpp
index e745a7b..5a09832 100644
--- a/server/test/ConfigurationComponent.cpp
+++ b/server/test/ConfigurationComponent.cpp
@@ -29,10 +29,10 @@ namespace
using namespace AsteriskSCF::System::Configuration::V1;
using namespace AsteriskSCF::System::Logger::V1;
-LoggingConfigurationPusher::LoggingConfigurationPusher(const ConfigurationServicePrx &config)
+LoggingConfigurationHelper::LoggingConfigurationHelper(const ConfigurationServicePrx &config)
: mConfigPrx(config) { }
-void LoggingConfigurationPusher::setLogOutFile(const std::string &fileName, int serialNumber)
+void LoggingConfigurationHelper::setLogOutFile(const std::string &fileName, int serialNumber)
{
ConfigurationGroupSeq groups;
LoggerGeneralGroupPtr generalGroup(new LoggerGeneralGroup);
@@ -43,7 +43,7 @@ void LoggingConfigurationPusher::setLogOutFile(const std::string &fileName, int
mConfigPrx->setConfiguration(groups);
}
-void LoggingConfigurationPusher::removeLogOutFile(const std::string &fileName)
+void LoggingConfigurationHelper::removeLogOutFile(const std::string &fileName)
{
ConfigurationGroupSeq groups;
LoggerGeneralGroupPtr generalGroup(new LoggerGeneralGroup);
@@ -52,3 +52,59 @@ void LoggingConfigurationPusher::removeLogOutFile(const std::string &fileName)
generalGroup->configurationItems.insert(make_pair(FileItemName, fileItem));
mConfigPrx->removeConfigurationItems(groups);
}
+
+AsteriskSCF::System::Logger::V1::FileItemPtr LoggingConfigurationHelper::getConfiguredOutputFile()
+{
+ //Part 1: Retrieval from the configuration service.
+
+ ConfigurationGroupSeq queryGroups;
+ LoggerGeneralGroupPtr generalGroup(new LoggerGeneralGroup);
+ FileItemPtr file(new FileItem);
+ generalGroup->configurationItems.insert(make_pair(FileItemName, file));
+ queryGroups.push_back(generalGroup);
+
+ ConfigurationGroupSeq returnedGroups = mConfigPrx->getConfiguration(queryGroups);
+
+ class Visitor : public LoggerConfigurationGroupVisitor
+ {
+ public:
+ Visitor(FileItemPtr &fileItem)
+ : returnFile(fileItem) { }
+ private:
+ void visitLoggerGeneralGroup(const LoggerGeneralGroupPtr &group)
+ {
+ class ItemVisitor : public LoggerConfigurationItemVisitor
+ {
+ public:
+ ItemVisitor(FileItemPtr &fileItem)
+ : returnFile(fileItem) { }
+ private:
+ void visitFileItem(const FileItemPtr &fileItem)
+ {
+ returnFile = fileItem;
+ }
+ FileItemPtr &returnFile;
+ };
+
+ LoggerConfigurationItemVisitorPtr generalVisitor = new ItemVisitor(returnFile);
+
+ for (ConfigurationItemDict::const_iterator item = group->configurationItems.begin();
+ item != group->configurationItems.end();
+ ++item)
+ {
+ item->second->visit(generalVisitor);
+ }
+ }
+ FileItemPtr &returnFile;
+ };
+
+ FileItemPtr returnFile = 0;
+ LoggerConfigurationGroupVisitorPtr v = new Visitor(returnFile);
+
+ for (ConfigurationGroupSeq::const_iterator group = returnedGroups.begin(); group != returnedGroups.end(); ++group)
+ {
+ (*group)->visit(v);
+ }
+
+ return returnFile;
+}
diff --git a/server/test/ConfigurationComponent.h b/server/test/ConfigurationComponent.h
index ab9a6ab..228fc36 100644
--- a/server/test/ConfigurationComponent.h
+++ b/server/test/ConfigurationComponent.h
@@ -19,13 +19,15 @@
*/
#include <AsteriskSCF/System/Component/ConfigurationIf.h>
+#include "LoggingConfigurationIf.h"
-class LoggingConfigurationPusher
+class LoggingConfigurationHelper
{
public:
- LoggingConfigurationPusher(const AsteriskSCF::System::Configuration::V1::ConfigurationServicePrx &config);
+ LoggingConfigurationHelper(const AsteriskSCF::System::Configuration::V1::ConfigurationServicePrx &config);
void setLogOutFile(const std::string &fileName, int serialNumber);
void removeLogOutFile(const std::string &fileName);
+ AsteriskSCF::System::Logger::V1::FileItemPtr getConfiguredOutputFile();
private:
AsteriskSCF::System::Configuration::V1::ConfigurationServicePrx mConfigPrx;
};
diff --git a/server/test/ConfigurationTest.cpp b/server/test/ConfigurationTest.cpp
index 748d258..736c76a 100644
--- a/server/test/ConfigurationTest.cpp
+++ b/server/test/ConfigurationTest.cpp
@@ -29,6 +29,7 @@
#include "ConfigurationComponent.h"
using namespace AsteriskSCF::System::Configuration::V1;
+using namespace AsteriskSCF::System::Logger::V1;
/* Cache the command line arguments so that Ice can be initialized within the global fixture. */
struct ArgCacheType
@@ -73,7 +74,7 @@ struct SharedTestData
{
Ice::CommunicatorPtr communicator;
Ice::ObjectAdapterPtr adapter;
- boost::shared_ptr<LoggingConfigurationPusher> confPusher;
+ boost::shared_ptr<LoggingConfigurationHelper> confHelper;
};
static SharedTestData TestBed;
@@ -94,7 +95,7 @@ struct GlobalIceFixture
TestBed.communicator = Ice::initialize(initData);
TestBed.adapter = TestBed.communicator->createObjectAdapterWithEndpoints("LoggerTestAdapter", "default");
Ice::ObjectPrx loggerObj = TestBed.communicator->propertyToProxy("LoggerServer.Proxy");
- TestBed.confPusher.reset(new LoggingConfigurationPusher(ConfigurationServicePrx::checkedCast(loggerObj)));
+ TestBed.confHelper.reset(new LoggingConfigurationHelper(ConfigurationServicePrx::checkedCast(loggerObj)));
}
catch (const Ice::Exception &ex)
{
@@ -118,6 +119,17 @@ BOOST_GLOBAL_FIXTURE(GlobalIceFixture);
static int serial = 100;
+static bool checkConfiguredFile(const boost::shared_ptr<LoggingConfigurationHelper> &confHelper,
+ const std::string &fileName)
+{
+ FileItemPtr configuredFile = confHelper->getConfiguredOutputFile();
+ if (configuredFile->fileName == fileName)
+ {
+ return true;
+ }
+ return false;
+}
+
// Basic test that sets a logging file to use and then
// Removes the configuration. If this doesn't work, then
// none of the other tests will work.
@@ -126,14 +138,14 @@ BOOST_AUTO_TEST_CASE(SetAndRemoveFile)
const std::string fileName("zombiebrains.txt");
try
{
- TestBed.confPusher->setLogOutFile(fileName, serial++);
+ TestBed.confHelper->setLogOutFile(fileName, serial++);
}
catch (const SerialConflict &sc)
{
- //We should not hit this
+ BOOST_FAIL("SerialConflict thrown when setting output file");
}
- //There should be one configured output file.
- TestBed.confPusher->removeLogOutFile(fileName);
+ checkConfiguredFile(TestBed.confHelper, fileName);
+ TestBed.confHelper->removeLogOutFile(fileName);
//There should be no configured output files.
}
@@ -143,24 +155,25 @@ BOOST_AUTO_TEST_CASE(FileReplacement)
const std::string fileName2("skeletonstomachs.txt");
try
{
- TestBed.confPusher->setLogOutFile(fileName1, serial++);
- //There should be one configured output file.
- TestBed.confPusher->setLogOutFile(fileName2, serial++);
+ TestBed.confHelper->setLogOutFile(fileName1, serial++);
+ bool correct = checkConfiguredFile(TestBed.confHelper, fileName1);
+ BOOST_CHECK(correct);
+ TestBed.confHelper->setLogOutFile(fileName2, serial++);
}
catch (const SerialConflict &sc)
{
- //We should not hit this
+ BOOST_FAIL("SerialConflict thrown when setting output file");
}
- //There should still be one configured output file. The
- //name of the output file should be different now.
- TestBed.confPusher->removeLogOutFile(fileName2);
+ bool correct = checkConfiguredFile(TestBed.confHelper, fileName2);
+ BOOST_CHECK(correct);
+ TestBed.confHelper->removeLogOutFile(fileName2);
//There should be no configured output files.
}
BOOST_AUTO_TEST_CASE(NonexistentRemoval)
{
const std::string fileName("frankensteinspleens.txt");
- TestBed.confPusher->removeLogOutFile(fileName);
+ TestBed.confHelper->removeLogOutFile(fileName);
//There should be no configured output files, and
//nothing catastrophic should have occurred.
}
@@ -171,15 +184,24 @@ BOOST_AUTO_TEST_CASE(PurposefulSerialConflict)
const std::string fileName2("ghostlungs.txt");
try
{
- TestBed.confPusher->setLogOutFile(fileName1, serial--);
- //There should be one configured output file.
- TestBed.confPusher->setLogOutFile(fileName2, serial++);
+ TestBed.confHelper->setLogOutFile(fileName1, serial--);
+ }
+ catch (const SerialConflict &ex)
+ {
+ BOOST_FAIL("SerialConflict thrown when setting output file");
+ }
+ bool correct = checkConfiguredFile(TestBed.confHelper, fileName1);
+ BOOST_CHECK(correct);
+ try
+ {
+ TestBed.confHelper->setLogOutFile(fileName2, serial++);
}
catch (const SerialConflict &ex)
{
- // We should hit this on the second call to setLogOutFile
+ // We should hit this.
}
- //There should be one configured output file, the old one.
+ correct = checkConfiguredFile(TestBed.confHelper, fileName1);
+ BOOST_CHECK(correct);
}
extern "C"
commit 90cdfbef42ca87e8c336ab54f6f02819d36ffb43
Author: Mark Michelson <mmichelson at digium.com>
Date: Tue Mar 15 15:26:03 2011 -0500
Add test case skeletons.
diff --git a/server/test/ConfigurationTest.cpp b/server/test/ConfigurationTest.cpp
index 51dcd14..748d258 100644
--- a/server/test/ConfigurationTest.cpp
+++ b/server/test/ConfigurationTest.cpp
@@ -19,12 +19,15 @@
#include <boost/test/unit_test.hpp>
#include <boost/test/debug.hpp>
+#include <boost/shared_ptr.hpp>
#include <Ice/Ice.h>
#include <IceBox/IceBox.h>
#include <AsteriskSCF/System/Component/ConfigurationIf.h>
+#include "ConfigurationComponent.h"
+
using namespace AsteriskSCF::System::Configuration::V1;
/* Cache the command line arguments so that Ice can be initialized within the global fixture. */
@@ -70,7 +73,7 @@ struct SharedTestData
{
Ice::CommunicatorPtr communicator;
Ice::ObjectAdapterPtr adapter;
- ConfigurationServicePrx loggerConfigurationServer;
+ boost::shared_ptr<LoggingConfigurationPusher> confPusher;
};
static SharedTestData TestBed;
@@ -91,12 +94,14 @@ struct GlobalIceFixture
TestBed.communicator = Ice::initialize(initData);
TestBed.adapter = TestBed.communicator->createObjectAdapterWithEndpoints("LoggerTestAdapter", "default");
Ice::ObjectPrx loggerObj = TestBed.communicator->propertyToProxy("LoggerServer.Proxy");
- TestBed.loggerConfigurationServer = ConfigurationServicePrx::checkedCast(loggerObj);
+ TestBed.confPusher.reset(new LoggingConfigurationPusher(ConfigurationServicePrx::checkedCast(loggerObj)));
}
catch (const Ice::Exception &ex)
{
std::cerr << ex << std::endl;
}
+
+
}
~GlobalIceFixture()
{
@@ -109,6 +114,74 @@ struct GlobalIceFixture
}
};
+BOOST_GLOBAL_FIXTURE(GlobalIceFixture);
+
+static int serial = 100;
+
+// Basic test that sets a logging file to use and then
+// Removes the configuration. If this doesn't work, then
+// none of the other tests will work.
+BOOST_AUTO_TEST_CASE(SetAndRemoveFile)
+{
+ const std::string fileName("zombiebrains.txt");
+ try
+ {
+ TestBed.confPusher->setLogOutFile(fileName, serial++);
+ }
+ catch (const SerialConflict &sc)
+ {
+ //We should not hit this
+ }
+ //There should be one configured output file.
+ TestBed.confPusher->removeLogOutFile(fileName);
+ //There should be no configured output files.
+}
+
+BOOST_AUTO_TEST_CASE(FileReplacement)
+{
+ const std::string fileName1("mummyhearts.txt");
+ const std::string fileName2("skeletonstomachs.txt");
+ try
+ {
+ TestBed.confPusher->setLogOutFile(fileName1, serial++);
+ //There should be one configured output file.
+ TestBed.confPusher->setLogOutFile(fileName2, serial++);
+ }
+ catch (const SerialConflict &sc)
+ {
+ //We should not hit this
+ }
+ //There should still be one configured output file. The
+ //name of the output file should be different now.
+ TestBed.confPusher->removeLogOutFile(fileName2);
+ //There should be no configured output files.
+}
+
+BOOST_AUTO_TEST_CASE(NonexistentRemoval)
+{
+ const std::string fileName("frankensteinspleens.txt");
+ TestBed.confPusher->removeLogOutFile(fileName);
+ //There should be no configured output files, and
+ //nothing catastrophic should have occurred.
+}
+
+BOOST_AUTO_TEST_CASE(PurposefulSerialConflict)
+{
+ const std::string fileName1("goblinlivers.txt");
+ const std::string fileName2("ghostlungs.txt");
+ try
+ {
+ TestBed.confPusher->setLogOutFile(fileName1, serial--);
+ //There should be one configured output file.
+ TestBed.confPusher->setLogOutFile(fileName2, serial++);
+ }
+ catch (const SerialConflict &ex)
+ {
+ // We should hit this on the second call to setLogOutFile
+ }
+ //There should be one configured output file, the old one.
+}
+
extern "C"
{
IceBox::Service* create(Ice::CommunicatorPtr communicator)
commit b2631be10abdb630e7f053c4aa2987006250bde7
Author: Mark Michelson <mmichelson at digium.com>
Date: Tue Mar 15 14:33:49 2011 -0500
Get some initial setup for the configuration test up and make sure it compiles.
This took waaaaaay longer than it should have.
diff --git a/server/test/CMakeLists.txt b/server/test/CMakeLists.txt
index d98c113..49486fc 100644
--- a/server/test/CMakeLists.txt
+++ b/server/test/CMakeLists.txt
@@ -15,10 +15,7 @@ include_directories(../../include)
asterisk_scf_component_add_file(logging-service-test LoggingServer-test.cpp)
asterisk_scf_component_add_file(logging-service-test server-test.cpp)
-asterisk_scf_component_add_file(logging-service-test ConfigurationComponent.cpp)
-asterisk_scf_component_add_file(logging-service-test ConfigurationComponent.h)
-asterisk_scf_component_add_slice(logging-service-test ../local-slice/LoggingConfigurationIf.ice)
asterisk_scf_component_add_boost_libraries(logging-service-test unit_test_framework)
include_directories(${API_INCLUDE_DIR})
@@ -27,4 +24,15 @@ target_link_libraries(logging-service-test asterisk-scf-api)
target_link_libraries(logging-service-test logging-service-lib)
+asterisk_scf_component_init(ConfigurationTest CXX)
+
+asterisk_scf_component_add_file(ConfigurationTest ConfigurationTest.cpp)
+asterisk_scf_component_add_file(ConfigurationTest ConfigurationComponent.cpp)
+asterisk_scf_component_add_file(ConfigurationTest ConfigurationComponent.h)
+asterisk_scf_component_add_slice(ConfigurationTest ../local-slice/LoggingConfigurationIf.ice)
+asterisk_scf_component_add_boost_libraries(ConfigurationTest unit_test_framework)
+include_directories(${API_INCLUDE_DIR})
+asterisk_scf_component_build_icebox(ConfigurationTest)
+target_link_libraries(ConfigurationTest asterisk-scf-api)
+
boost_add_test(logging-service-test)
diff --git a/server/test/ConfigurationTest.cpp b/server/test/ConfigurationTest.cpp
new file mode 100644
index 0000000..51dcd14
--- /dev/null
+++ b/server/test/ConfigurationTest.cpp
@@ -0,0 +1,118 @@
+/*
+ * Asterisk SCF -- An open-source communications framework.
+ *
+ * Copyright (C) 2010, Digium, Inc.
+ *
+ * See http://www.asterisk.org for more information about
+ * the Asterisk SCF project. Please do not directly contact
+ * any of the maintainers of this project for assistance;
+ * the project provides a web site, mailing lists and IRC
+ * channels for your use.
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License Version 2. See the LICENSE.txt file
+ * at the top of the source tree.
+ */
+
+#define BOOST_TEST_MODULE LoggerTestSuite
+#define BOOST_TEST_NO_MAIN
+
+#include <boost/test/unit_test.hpp>
+#include <boost/test/debug.hpp>
+
+#include <Ice/Ice.h>
+#include <IceBox/IceBox.h>
+
+#include <AsteriskSCF/System/Component/ConfigurationIf.h>
+
+using namespace AsteriskSCF::System::Configuration::V1;
+
+/* Cache the command line arguments so that Ice can be initialized within the global fixture. */
+struct ArgCacheType
+{
+public:
+ int argc;
+ char **argv;
+ Ice::PropertiesPtr inheritedProps;
+};
+static ArgCacheType mCachedArgs;
+
+class LoggerConfigurationTest : public IceBox::Service
+{
+public:
+ void start(const std::string &name,
+ const Ice::CommunicatorPtr &communicator,
+ const Ice::StringSeq &args)
+ {
+ std::vector<char const *> argv;
+ argv.push_back(name.c_str());
+ for (Ice::StringSeq::const_iterator i = args.begin();
+ i != args.end();
+ ++i)
+ {
+ argv.push_back(i->c_str());
+ }
+ // null terminated list
+ argv.push_back((const char *) 0);
+
+ mCachedArgs.argc = argv.size() - 1;
+ mCachedArgs.argv = (char**)&argv[0];
+
+ int r = ::boost::unit_test::unit_test_main(&init_unit_test, mCachedArgs.argc, mCachedArgs.argv);
+ exit(r);
+
+ }
+
+ void stop() { }
+};
+
+struct SharedTestData
+{
+ Ice::CommunicatorPtr communicator;
+ Ice::ObjectAdapterPtr adapter;
+ ConfigurationServicePrx loggerConfigurationServer;
+};
+
+static SharedTestData TestBed;
+
+struct GlobalIceFixture
+{
+ GlobalIceFixture()
+ {
+ BOOST_TEST_MESSAGE("Setting up Logger Server global test fixture");
+ ::boost::debug::detect_memory_leaks(false);
+ ::boost::unit_test::unit_test_log.set_stream(std::cout);
+
+ try
+ {
+ Ice::InitializationData initData;
+ initData.properties = mCachedArgs.inheritedProps;
+
+ TestBed.communicator = Ice::initialize(initData);
+ TestBed.adapter = TestBed.communicator->createObjectAdapterWithEndpoints("LoggerTestAdapter", "default");
+ Ice::ObjectPrx loggerObj = TestBed.communicator->propertyToProxy("LoggerServer.Proxy");
+ TestBed.loggerConfigurationServer = ConfigurationServicePrx::checkedCast(loggerObj);
+ }
+ catch (const Ice::Exception &ex)
+ {
+ std::cerr << ex << std::endl;
+ }
+ }
+ ~GlobalIceFixture()
+ {
+ BOOST_TEST_MESSAGE("Killing the Logging Server global test fixture");
+ if (TestBed.communicator)
+ {
+ TestBed.communicator->shutdown();
+ TestBed.communicator = 0;
+ }
+ }
+};
+
+extern "C"
+{
+IceBox::Service* create(Ice::CommunicatorPtr communicator)
+{
+ return new LoggerConfigurationTest;
+}
+}
commit 89913e2ec673202c8ad86138f77cbd51ec4304b8
Author: Mark Michelson <mmichelson at digium.com>
Date: Mon Mar 14 17:08:15 2011 -0500
Start tweaking server tests to include configuration test.
This push contains some simple code to be able to add or remove
output file configuration. The real meat will be the code that uses
this class to push code to a running logging server. Hi.
diff --git a/server/test/CMakeLists.txt b/server/test/CMakeLists.txt
index 94b4643..d98c113 100644
--- a/server/test/CMakeLists.txt
+++ b/server/test/CMakeLists.txt
@@ -6,6 +6,8 @@
# All rights reserved.
#
+asterisk_scf_slice_include_directories(${API_SLICE_DIR})
+
asterisk_scf_component_init(logging-service-test CXX)
include_directories(../src)
@@ -13,7 +15,10 @@ include_directories(../../include)
asterisk_scf_component_add_file(logging-service-test LoggingServer-test.cpp)
asterisk_scf_component_add_file(logging-service-test server-test.cpp)
+asterisk_scf_component_add_file(logging-service-test ConfigurationComponent.cpp)
+asterisk_scf_component_add_file(logging-service-test ConfigurationComponent.h)
+asterisk_scf_component_add_slice(logging-service-test ../local-slice/LoggingConfigurationIf.ice)
asterisk_scf_component_add_boost_libraries(logging-service-test unit_test_framework)
include_directories(${API_INCLUDE_DIR})
diff --git a/server/test/ConfigurationComponent.cpp b/server/test/ConfigurationComponent.cpp
new file mode 100644
index 0000000..e745a7b
--- /dev/null
+++ b/server/test/ConfigurationComponent.cpp
@@ -0,0 +1,54 @@
+/*
+ * Asterisk SCF -- An open-source communications framework.
+ *
+ * Copyright (C) 2011, Digium, Inc.
+ *
+ * See http://www.asterisk.org for more information about
+ * the Asterisk SCF project. Please do not directly contact
+ * any of the maintainers of this project for assistance;
+ * the project provides a web site, mailing lists and IRC
+ * channels for your use.
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License Version 2. See the LICENSE.txt file
+ * at the top of the source tree.
+ */
+
+/**
+ * This is a component that pushes test data to the logging server.
+ */
+
+#include "ConfigurationComponent.h"
+#include "LoggingConfigurationIf.h"
+
+namespace
+{
+ const std::string FileItemName("file");
+};
+
+using namespace AsteriskSCF::System::Configuration::V1;
+using namespace AsteriskSCF::System::Logger::V1;
+
+LoggingConfigurationPusher::LoggingConfigurationPusher(const ConfigurationServicePrx &config)
+ : mConfigPrx(config) { }
+
+void LoggingConfigurationPusher::setLogOutFile(const std::string &fileName, int serialNumber)
+{
+ ConfigurationGroupSeq groups;
+ LoggerGeneralGroupPtr generalGroup(new LoggerGeneralGroup);
+ FileItemPtr fileItem(new FileItem);
+ fileItem->fileName = fileName;
+ fileItem->serialNumber = serialNumber;
+ generalGroup->configurationItems.insert(make_pair(FileItemName, fileItem));
+ mConfigPrx->setConfiguration(groups);
+}
+
+void LoggingConfigurationPusher::removeLogOutFile(const std::string &fileName)
+{
+ ConfigurationGroupSeq groups;
+ LoggerGeneralGroupPtr generalGroup(new LoggerGeneralGroup);
+ FileItemPtr fileItem(new FileItem);
+ fileItem->fileName = fileName;
+ generalGroup->configurationItems.insert(make_pair(FileItemName, fileItem));
+ mConfigPrx->removeConfigurationItems(groups);
+}
diff --git a/server/test/ConfigurationComponent.h b/server/test/ConfigurationComponent.h
new file mode 100644
index 0000000..ab9a6ab
--- /dev/null
+++ b/server/test/ConfigurationComponent.h
@@ -0,0 +1,31 @@
+/*
+ * Asterisk SCF -- An open-source communications framework.
+ *
+ * Copyright (C) 2011, Digium, Inc.
+ *
+ * See http://www.asterisk.org for more information about
+ * the Asterisk SCF project. Please do not directly contact
+ * any of the maintainers of this project for assistance;
+ * the project provides a web site, mailing lists and IRC
+ * channels for your use.
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License Version 2. See the LICENSE.txt file
+ * at the top of the source tree.
+ */
+
+/**
+ * This is a component that pushes test data to the logging server.
+ */
+
+#include <AsteriskSCF/System/Component/ConfigurationIf.h>
+
+class LoggingConfigurationPusher
+{
+public:
+ LoggingConfigurationPusher(const AsteriskSCF::System::Configuration::V1::ConfigurationServicePrx &config);
+ void setLogOutFile(const std::string &fileName, int serialNumber);
+ void removeLogOutFile(const std::string &fileName);
+private:
+ AsteriskSCF::System::Configuration::V1::ConfigurationServicePrx mConfigPrx;
+};
commit df11e7299041cb14c0e7e6ae16bacab26684ee4e
Author: Mark Michelson <mmichelson at digium.com>
Date: Mon Mar 14 14:24:00 2011 -0500
Add Configuration service to the object adapter.
I also changed the name of the ConfigurationService to
LoggerConfigurationService to resolve some ambiguity in
class names. The compiler could handle it all right, but it
makes things easier for human eyes.
diff --git a/server/src/Configuration.cpp b/server/src/Configuration.cpp
index 86f65bd..34685c8 100644
--- a/server/src/Configuration.cpp
+++ b/server/src/Configuration.cpp
@@ -69,10 +69,10 @@ public:
typedef boost::shared_ptr<ConfigurationServiceImpl> ConfigurationServiceImplPtr;
-ConfigurationService::ConfigurationService(LoggingServerIPtr server)
+LoggerConfigurationService::LoggerConfigurationService(LoggingServerIPtr server)
: mImpl(new ConfigurationServiceImpl(server)) { }
-ConfigurationGroupSeq ConfigurationService::getConfiguration(const ConfigurationGroupSeq& groups, const Ice::Current&)
+ConfigurationGroupSeq LoggerConfigurationService::getConfiguration(const ConfigurationGroupSeq& groups, const Ice::Current&)
{
class visitor : public LoggerConfigurationGroupVisitor
{
@@ -130,7 +130,7 @@ ConfigurationGroupSeq ConfigurationService::getConfiguration(const Configuration
return newGroups;
}
-ConfigurationGroupSeq ConfigurationService::getConfigurationAll(const ConfigurationGroupSeq& groups, const Ice::Current&)
+ConfigurationGroupSeq LoggerConfigurationService::getConfigurationAll(const ConfigurationGroupSeq& groups, const Ice::Current&)
{
class visitor : public LoggerConfigurationGroupVisitor
{
@@ -163,7 +163,7 @@ ConfigurationGroupSeq ConfigurationService::getConfigurationAll(const Configurat
return newGroups;
}
-ConfigurationGroupSeq ConfigurationService::getConfigurationGroups(const Ice::Current&)
+ConfigurationGroupSeq LoggerConfigurationService::getConfigurationGroups(const Ice::Current&)
{
ConfigurationGroupSeq groups;
@@ -176,7 +176,7 @@ ConfigurationGroupSeq ConfigurationService::getConfigurationGroups(const Ice::Cu
return groups;
}
-void ConfigurationService::setConfiguration(const ConfigurationGroupSeq& groups, const Ice::Current&)
+void LoggerConfigurationService::setConfiguration(const ConfigurationGroupSeq& groups, const Ice::Current&)
{
class GroupsVisitor : public LoggerConfigurationGroupVisitor
{
@@ -266,7 +266,7 @@ void ConfigurationService::setConfiguration(const ConfigurationGroupSeq& groups,
}
}
-void ConfigurationService::removeConfigurationItems(const ConfigurationGroupSeq& groups, const Ice::Current&)
+void LoggerConfigurationService::removeConfigurationItems(const ConfigurationGroupSeq& groups, const Ice::Current&)
{
class GroupsVisitor : public LoggerConfigurationGroupVisitor
{
@@ -331,7 +331,7 @@ void ConfigurationService::removeConfigurationItems(const ConfigurationGroupSeq&
}
}
-void ConfigurationService::removeConfigurationGroups(const ConfigurationGroupSeq& groups, const Ice::Current&)
+void LoggerConfigurationService::removeConfigurationGroups(const ConfigurationGroupSeq& groups, const Ice::Current&)
{
class visitor : public LoggerConfigurationGroupVisitor
{
diff --git a/server/src/Configuration.h b/server/src/Configuration.h
index 3b5b8b6..64125a9 100644
--- a/server/src/Configuration.h
+++ b/server/src/Configuration.h
@@ -42,10 +42,10 @@ class ConfigurationServiceImpl;
/**
* Implementation of the configuration service.
*/
-class ConfigurationService : public AsteriskSCF::System::Configuration::V1::ConfigurationService
+class LoggerConfigurationService : public AsteriskSCF::System::Configuration::V1::ConfigurationService
{
public:
- ConfigurationService(LoggingServerIPtr server);
+ LoggerConfigurationService(LoggingServerIPtr server);
AsteriskSCF::System::Configuration::V1::ConfigurationGroupSeq getConfiguration(const AsteriskSCF::System::Configuration::V1::ConfigurationGroupSeq&, const Ice::Current&);
AsteriskSCF::System::Configuration::V1::ConfigurationGroupSeq getConfigurationAll(const AsteriskSCF::System::Configuration::V1::ConfigurationGroupSeq&, const Ice::Current&);
AsteriskSCF::System::Configuration::V1::ConfigurationGroupSeq getConfigurationGroups(const Ice::Current&);
diff --git a/server/src/LoggingServer.h b/server/src/LoggingServer.h
index 9c672b0..5d6f3b0 100644
--- a/server/src/LoggingServer.h
+++ b/server/src/LoggingServer.h
@@ -106,7 +106,7 @@ private:
std::vector<boost::shared_ptr<ChainedLogOut> > mLogsOut;
... 1179 lines suppressed ...
--
asterisk-scf/release/logger.git
More information about the asterisk-scf-commits
mailing list