diff --git a/utils/test/com/cloud/utils/TestProfiler.java b/utils/test/com/cloud/utils/TestProfiler.java index 2690a262e76..4323f1d3c71 100644 --- a/utils/test/com/cloud/utils/TestProfiler.java +++ b/utils/test/com/cloud/utils/TestProfiler.java @@ -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()); + } +} \ No newline at end of file