--- /dev/null
+/*
+The software in this package is distributed under the GNU General
+Public License version 2 (with a special exception described below).
+
+A copy of GNU General Public License (GPL) is included in this distribution,
+in the file COPYING.GPL.
+
+As a special exception, if other files instantiate templates or use macros
+or inline functions from this file, or you compile this file and link it
+with other works to produce a work based on this file, this file
+does not by itself cause the resulting work to be covered
+by the GNU General Public License.
+
+However the source code for this file must still be made available
+in accordance with section (3) of the GNU General Public License.
+
+This exception does not invalidate any other reasons why a work based
+on this file might be covered by the GNU General Public License.
+*/
+#ifndef STATUS_NOTIFIER_COMMAND_H
+#define STATUS_NOTIFIER_COMMAND_H
+
+#include <string>
+
+#include <boost/scoped_ptr.hpp>
+
+#define UNDER_TEST
+
+//-----------------------------------------------------------------------------
+// StatusNotifierCommand
+//-----------------------------------------------------------------------------
+
+/**
+ * @brief This class provides methods to handle status-notifier-cmd
+ * configuration.
+ */
+class StatusNotifierCommand
+{
+public:
+ static const std::string StatusToken;
+
+public:
+ explicit StatusNotifierCommand( const std::string &status_notifier_cmd );
+ virtual ~StatusNotifierCommand();
+
+ bool set_token_value(
+ const std::string &token,
+ const std::string &value
+ );
+ std::string get_token_value() const;
+
+ bool execute() const;
+};
+
+//-----------------------------------------------------------------------------
+// StatusNotifierCommandItem
+//-----------------------------------------------------------------------------
+
+typedef boost::scoped_ptr<StatusNotifierCommand> StatusNotifierCommandItem;
+
+//-----------------------------------------------------------------------------
+
+const std::string StatusNotifierCommand::StatusToken("${status}");
+
+//-----------------------------------------------------------------------------
+
+StatusNotifierCommand::StatusNotifierCommand(
+ const std::string &
+)
+{
+}
+
+StatusNotifierCommand::~StatusNotifierCommand()
+{
+}
+
+bool StatusNotifierCommand::set_token_value(
+ const std::string &,
+ const std::string &value
+)
+{
+ return true;
+}
+
+std::string StatusNotifierCommand::get_token_value() const
+{
+ return std::string();
+}
+
+bool StatusNotifierCommand::execute() const
+{
+ return true;
+}
+
+#endif // STATUS_NOTIFIER_COMMAND_H
--- /dev/null
+/*
+The software in this package is distributed under the GNU General
+Public License version 2 (with a special exception described below).
+
+A copy of GNU General Public License (GPL) is included in this distribution,
+in the file COPYING.GPL.
+
+As a special exception, if other files instantiate templates or use macros
+or inline functions from this file, or you compile this file and link it
+with other works to produce a work based on this file, this file
+does not by itself cause the resulting work to be covered
+by the GNU General Public License.
+
+However the source code for this file must still be made available
+in accordance with section (3) of the GNU General Public License.
+
+This exception does not invalidate any other reasons why a work based
+on this file might be covered by the GNU General Public License.
+*/
+
+#define BOOST_TEST_MAIN
+#define BOOST_TEST_DYN_LINK
+
+#include <streambuf>
+
+#include <boost/asio.hpp>
+#include <boost/test/unit_test.hpp>
+#include <boost/thread.hpp>
+
+#include "mock_statusnotifiercommand.h"
+
+#include "link/linkstatus.h"
+
+BOOST_AUTO_TEST_SUITE( TestLinkStatus )
+
+BOOST_AUTO_TEST_CASE( is_link_up_enough_time )
+{
+ int hosts_down_limit = 2;
+ int link_up_interval_in_min = 0;
+ int link_down_interval_in_min = 1;
+
+ std::string status_notifier_cmd = "none";
+
+ LinkStatus link_status(
+ hosts_down_limit,
+ link_up_interval_in_min,
+ link_down_interval_in_min,
+ status_notifier_cmd
+ );
+
+ link_status.notify_host_up( "www.intra2net.com" );
+ BOOST_CHECK_EQUAL( link_status.is_link_up_enough_time(), true );
+}
+
+BOOST_AUTO_TEST_CASE( is_link_down_enough_time )
+{
+ int hosts_down_limit = 2;
+ int link_up_interval_in_min = 1;
+ int link_down_interval_in_min = 0;
+
+ std::string status_notifier_cmd = "none";
+
+ LinkStatus link_status(
+ hosts_down_limit,
+ link_up_interval_in_min,
+ link_down_interval_in_min,
+ status_notifier_cmd
+ );
+
+ link_status.notify_host_down( "www.intra2net.com" );
+ BOOST_CHECK_EQUAL( link_status.is_link_down_enough_time(), true );
+}
+
+BOOST_AUTO_TEST_CASE( exceeded_host_down_limit )
+{
+ int hosts_down_limit = 2;
+ int link_up_interval_in_min = 1;
+ int link_down_interval_in_min = 1;
+
+ std::string status_notifier_cmd = "none";
+
+ LinkStatus link_status(
+ hosts_down_limit,
+ link_up_interval_in_min,
+ link_down_interval_in_min,
+ status_notifier_cmd
+ );
+
+ link_status.notify_host_down( "www.intra2net.com" );
+ BOOST_CHECK_EQUAL( link_status.exceeded_host_down_limit(), false );
+
+ link_status.notify_host_down( "www.ufsc.br" );
+ BOOST_CHECK_EQUAL( link_status.exceeded_host_down_limit(), false );
+
+ link_status.notify_host_down( "www.google.com" );
+ BOOST_CHECK_EQUAL( link_status.exceeded_host_down_limit(), true );
+
+ link_status.notify_host_down( "www.fazenda.gov.br" );
+ BOOST_CHECK_EQUAL( link_status.exceeded_host_down_limit(), true );
+}
+
+BOOST_AUTO_TEST_SUITE_END()