Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Sebastian Schrader
Kea
Commits
d55bcb9c
Commit
d55bcb9c
authored
Jan 17, 2011
by
JINMEI Tatuya
Browse files
added a trivial method IntervalTimer::getInterval() for the convenient of
other tests.
parent
692e3a1c
Changes
6
Hide whitespace changes
Inline
Side-by-side
src/bin/auth/auth.spec.pre.in
View file @
d55bcb9c
...
...
@@ -52,6 +52,11 @@
}
]
}
},
{ "item_name": "statistics-interval",
"item_type": "integer",
"item_optional": true,
"item_default": 60
}
],
"commands": [
...
...
src/bin/auth/config.cc
View file @
d55bcb9c
...
...
@@ -169,6 +169,18 @@ MemoryDatasourceConfig::build(ConstElementPtr config_value) {
}
}
class
StatisticsIntervalConfig
:
public
AuthConfigParser
{
public:
StatisticsIntervalConfig
(
AuthSrv
&
server
)
:
server_
(
server
)
{}
//virtual void build(ConstElementPtr config_value);
virtual
void
build
(
ConstElementPtr
)
{}
virtual
void
commit
()
{}
private:
AuthSrv
&
server_
;
};
/// A special parser for testing: it throws from commit() despite the
/// suggested convention of the class interface.
class
ThrowerCommitConfig
:
public
AuthConfigParser
{
...
...
@@ -191,6 +203,8 @@ createAuthConfigParser(AuthSrv& server, const std::string& config_id,
// that it can be dynamically customized.
if
(
config_id
==
"datasources"
)
{
return
(
new
DatasourcesConfig
(
server
));
}
else
if
(
config_id
==
"statistics-interval"
)
{
return
(
new
StatisticsIntervalConfig
(
server
));
}
else
if
(
internal
&&
config_id
==
"datasources/memory"
)
{
return
(
new
MemoryDatasourceConfig
(
server
));
}
else
if
(
config_id
==
"_commit_throw"
)
{
...
...
src/bin/auth/tests/config_unittest.cc
View file @
d55bcb9c
...
...
@@ -320,4 +320,23 @@ TEST_F(MemoryDatasrcConfigTest, badDatasrcType) {
" {
\"
type
\"
:
\"
memory
\"
}]"
)),
AuthConfigError
);
}
class
StatisticsIntervalConfigTest
:
public
AuthConfigTest
{
protected:
StatisticsIntervalConfigTest
()
:
parser
(
createAuthConfigParser
(
server
,
"statistics-interval"
))
{
server
.
setStatisticsSession
(
&
statistics_session
);
}
~
StatisticsIntervalConfigTest
()
{
delete
parser
;
}
MockSession
statistics_session
;
AuthConfigParser
*
parser
;
};
TEST_F
(
StatisticsIntervalConfigTest
,
setInterval
)
{
parser
->
build
(
Element
::
fromJSON
(
"1"
));
parser
->
commit
();
}
}
src/lib/asiolink/asiolink.cc
View file @
d55bcb9c
...
...
@@ -386,6 +386,7 @@ public:
void
setupTimer
(
const
IntervalTimer
::
Callback
&
cbfunc
,
const
uint32_t
interval
);
void
callback
(
const
asio
::
error_code
&
error
);
uint32_t
getInterval
()
const
{
return
(
interval_
);
}
private:
// a function to update timer_ when it expires
void
updateTimer
();
...
...
@@ -461,4 +462,9 @@ IntervalTimer::setupTimer(const Callback& cbfunc, const uint32_t interval) {
return
(
impl_
->
setupTimer
(
cbfunc
,
interval
));
}
uint32_t
IntervalTimer
::
getInterval
()
const
{
return
(
impl_
->
getInterval
());
}
}
src/lib/asiolink/asiolink.h
View file @
d55bcb9c
...
...
@@ -657,6 +657,10 @@ public:
/// \throw isc::Unexpected ASIO library error
///
void
setupTimer
(
const
Callback
&
cbfunc
,
const
uint32_t
interval
);
/// TBD
uint32_t
getInterval
()
const
;
private:
IntervalTimerImpl
*
impl_
;
};
...
...
src/lib/asiolink/tests/asiolink_unittest.cc
View file @
d55bcb9c
...
...
@@ -864,6 +864,7 @@ TEST_F(IntervalTimerTest, startIntervalTimer) {
start
=
boost
::
posix_time
::
microsec_clock
::
universal_time
();
// setup timer
itimer
.
setupTimer
(
TimerCallBack
(
this
),
1
);
EXPECT_EQ
(
1
,
itimer
.
getInterval
());
io_service_
.
run
();
// reaches here after timer expired
// delta: difference between elapsed time and 1 second
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment