You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ja...@apache.org on 2015/06/29 09:00:33 UTC
[12/50] [abbrv] git commit: updated refs/heads/dhcpoffload to 45721ae
Add unit tests to cover negative cases
- Cover when the profile is not started/stopped
Signed-off-by: wilderrodrigues <wr...@schubergphilis.com>
This closes #509
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/f29bf1e8
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/f29bf1e8
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/f29bf1e8
Branch: refs/heads/dhcpoffload
Commit: f29bf1e85c84f7a7c91ff9521b41b32532f737ee
Parents: 78c802a
Author: wilderrodrigues <wr...@schubergphilis.com>
Authored: Mon Jun 22 16:05:15 2015 +0200
Committer: wilderrodrigues <wr...@schubergphilis.com>
Committed: Tue Jun 23 10:03:20 2015 +0200
----------------------------------------------------------------------
utils/test/com/cloud/utils/TestProfiler.java | 32 ++++++++++++++++++++---
1 file changed, 29 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f29bf1e8/utils/test/com/cloud/utils/TestProfiler.java
----------------------------------------------------------------------
diff --git a/utils/test/com/cloud/utils/TestProfiler.java b/utils/test/com/cloud/utils/TestProfiler.java
index 2690a26..4323f1d 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