[asterisk-scf-commits] asterisk-scf/integration/logger.git branch "filename" updated.

Commits to the Asterisk SCF project code repositories asterisk-scf-commits at lists.digium.com
Wed Apr 20 16:56:43 CDT 2011


branch "filename" has been updated
       via  7fad057cd987478e5b66c376febc4ac8b5437037 (commit)
       via  12c8fe7c473a36d690054c7c6d81571990b63cc1 (commit)
       via  484f42421c3e0de5da362a42109ae8c5ccc49db8 (commit)
      from  356e1ce8ebfe6b996a7a82f45497a0cbcc6f263a (commit)

Summary of changes:
 server/CMakeLists.txt                              |    1 +
 ...oggingserver.conf => testloggingserver.conf.in} |    5 ++-
 server/src/Configuration.cpp                       |   43 +++++++++++---------
 server/test/CMakeLists.txt                         |   20 +++++----
 server/test/ConfigurationTest.cpp                  |   11 ++++-
 server/test/LoggingConfigurationHelper.cpp         |    3 +-
 6 files changed, 49 insertions(+), 34 deletions(-)
 rename server/config/{testloggingserver.conf => testloggingserver.conf.in} (55%)


- Log -----------------------------------------------------------------
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);

-----------------------------------------------------------------------


-- 
asterisk-scf/integration/logger.git



More information about the asterisk-scf-commits mailing list