mirror of
https://github.com/apache/cloudstack.git
synced 2025-11-02 20:02:29 +01:00
Add unit tests to cover negative cases
- Cover when the profile is not started/stopped Signed-off-by: wilderrodrigues <wrodrigues@schubergphilis.com> This closes #509
This commit is contained in:
parent
78c802a539
commit
f29bf1e85c
@ -32,11 +32,11 @@ public class TestProfiler extends Log4jEnabledTestCase {
|
||||
public void testProfiler() {
|
||||
s_logger.info("testProfiler() started");
|
||||
|
||||
Profiler pf = new Profiler();
|
||||
final Profiler pf = new Profiler();
|
||||
pf.start();
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
} catch (InterruptedException e) {
|
||||
} catch (final InterruptedException e) {
|
||||
}
|
||||
pf.stop();
|
||||
|
||||
@ -46,4 +46,30 @@ public class TestProfiler extends Log4jEnabledTestCase {
|
||||
|
||||
s_logger.info("testProfiler() stopped");
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testProfilerNoStart() {
|
||||
final Profiler pf = new Profiler();
|
||||
try {
|
||||
Thread.sleep(20);
|
||||
} catch (final InterruptedException e) {
|
||||
}
|
||||
pf.stop();
|
||||
|
||||
Assert.assertTrue(pf.getDuration() == -1);
|
||||
Assert.assertFalse(pf.isStarted());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testProfilerNoStop() {
|
||||
final Profiler pf = new Profiler();
|
||||
pf.start();
|
||||
try {
|
||||
Thread.sleep(20);
|
||||
} catch (final InterruptedException e) {
|
||||
}
|
||||
|
||||
Assert.assertTrue(pf.getDuration() == -1);
|
||||
Assert.assertFalse(pf.isStopped());
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user