{"action":"created","comment":{"url":"https://api.github.com/repos/Alluxio/alluxio/pulls/comments/63759481","id":63759481,"diff_hunk":"@@ -0,0 +1,100 @@\n+/*\n+ * The Alluxio Open Foundation licenses this work under the Apache License, version 2.0\n+ * (the “License”). You may not use this work except in compliance with the License, which is\n+ * available at www.apache.org/licenses/LICENSE-2.0\n+ *\n+ * This software is distributed on an \"AS IS\" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,\n+ * either express or implied, as more fully set forth in the License.\n+ *\n+ * See the NOTICE file distributed with this work for information regarding copyright ownership.\n+ */\n+\n+package alluxio.heartbeat;\n+\n+import org.junit.Assert;\n+import org.junit.Test;\n+import org.junit.runner.RunWith;\n+import org.mockito.Mockito;\n+import org.powermock.core.classloader.annotations.PrepareForTest;\n+import org.powermock.modules.junit4.PowerMockRunner;\n+import org.powermock.reflect.Whitebox;\n+import org.slf4j.Logger;\n+\n+import alluxio.util.CommonUtils;\n+\n+/**\n+ * Unit tests for {@link SleepingTimer}. It tests three scenarios listed below:\n+ * 1. Sleep more than the interval of SleepingTimer and see if the SleepingTimer warns correctly;\n+ * 2. Tick continuously for several times and see if the time interval is correct;\n+ * 3. Sleep less than the interval of SleepingTimer and see if the time interval is correct.\n+ */\n+\n+@RunWith(PowerMockRunner.class)\n+@PrepareForTest({SleepingTimer.class})\n+public class SleepingTimerTest {\n+  private static final String THREAD_NAME = \"sleepingtimer-test-thread-name\";\n+  private static final long INTERVAL_MS = 500;\n+\n+  /**\n+   *  This is a test to make sure that SleepingTimer should warn when execution time\n+   *  is longer than interval.\n+   */\n+  @Test\n+  public void executeLongerThanIntervalTest() throws Exception {\n+    SleepingTimer stimer = new SleepingTimer(THREAD_NAME, INTERVAL_MS);","path":"core/common/src/test/java/alluxio/heartbeat/SleepingTimerTest.java","position":44,"original_position":44,"commit_id":"3837f73b36ce230f049e4a71f192aa35467be49c","original_commit_id":"3837f73b36ce230f049e4a71f192aa35467be49c","user":{"login":"apc999","id":1413748,"avatar_url":"https://avatars.githubusercontent.com/u/1413748?v=3","gravatar_id":"","url":"https://api.github.com/users/apc999","html_url":"https://github.com/apc999","followers_url":"https://api.github.com/users/apc999/followers","following_url":"https://api.github.com/users/apc999/following{/other_user}","gists_url":"https://api.github.com/users/apc999/gists{/gist_id}","starred_url":"https://api.github.com/users/apc999/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apc999/subscriptions","organizations_url":"https://api.github.com/users/apc999/orgs","repos_url":"https://api.github.com/users/apc999/repos","events_url":"https://api.github.com/users/apc999/events{/privacy}","received_events_url":"https://api.github.com/users/apc999/received_events","type":"User","site_admin":false},"body":"since all three test cases share the same setup, it will be better to consolidate them into a `before` method, this is the convention we have in Alluxio. check out the other tests we use ","created_at":"2016-05-18T18:45:33Z","updated_at":"2016-05-18T18:45:33Z","html_url":"https://github.com/Alluxio/alluxio/pull/3298#discussion_r63759481","pull_request_url":"https://api.github.com/repos/Alluxio/alluxio/pulls/3298","_links":{"self":{"href":"https://api.github.com/repos/Alluxio/alluxio/pulls/comments/63759481"},"html":{"href":"https://github.com/Alluxio/alluxio/pull/3298#discussion_r63759481"},"pull_request":{"href":"https://api.github.com/repos/Alluxio/alluxio/pulls/3298"}}},"pull_request":{"url":"https://api.github.com/repos/Alluxio/alluxio/pulls/3298","id":70434812,"html_url":"https://github.com/Alluxio/alluxio/pull/3298","diff_url":"https://github.com/Alluxio/alluxio/pull/3298.diff","patch_url":"https://github.com/Alluxio/alluxio/pull/3298.patch","issue_url":"https://api.github.com/repos/Alluxio/alluxio/issues/3298","number":3298,"state":"open","locked":false,"title":"[ALLUXIO-1790] Add unit test coverage for class SleepingTimer","user":{"login":"xhad1234","id":4424966,"avatar_url":"https://avatars.githubusercontent.com/u/4424966?v=3","gravatar_id":"","url":"https://api.github.com/users/xhad1234","html_url":"https://github.com/xhad1234","followers_url":"https://api.github.com/users/xhad1234/followers","following_url":"https://api.github.com/users/xhad1234/following{/other_user}","gists_url":"https://api.github.com/users/xhad1234/gists{/gist_id}","starred_url":"https://api.github.com/users/xhad1234/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xhad1234/subscriptions","organizations_url":"https://api.github.com/users/xhad1234/orgs","repos_url":"https://api.github.com/users/xhad1234/repos","events_url":"https://api.github.com/users/xhad1234/events{/privacy}","received_events_url":"https://api.github.com/users/xhad1234/received_events","type":"User","site_admin":false},"body":"https://alluxio.atlassian.net/browse/ALLUXIO-1790?jql=project%20%3D%20ALLUXIO%20AND%20labels%20%3D%20NewContributor%20AND%20status%20%3D%20OPEN","created_at":"2016-05-17T21:36:31Z","updated_at":"2016-05-18T18:45:33Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2bd29ff75ad8303246a8bf6e4ca222ba17c94c3e","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/Alluxio/alluxio/pulls/3298/commits","review_comments_url":"https://api.github.com/repos/Alluxio/alluxio/pulls/3298/comments","review_comment_url":"https://api.github.com/repos/Alluxio/alluxio/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Alluxio/alluxio/issues/3298/comments","statuses_url":"https://api.github.com/repos/Alluxio/alluxio/statuses/3837f73b36ce230f049e4a71f192aa35467be49c","head":{"label":"xhad1234:master","ref":"master","sha":"3837f73b36ce230f049e4a71f192aa35467be49c","user":{"login":"xhad1234","id":4424966,"avatar_url":"https://avatars.githubusercontent.com/u/4424966?v=3","gravatar_id":"","url":"https://api.github.com/users/xhad1234","html_url":"https://github.com/xhad1234","followers_url":"https://api.github.com/users/xhad1234/followers","following_url":"https://api.github.com/users/xhad1234/following{/other_user}","gists_url":"https://api.github.com/users/xhad1234/gists{/gist_id}","starred_url":"https://api.github.com/users/xhad1234/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xhad1234/subscriptions","organizations_url":"https://api.github.com/users/xhad1234/orgs","repos_url":"https://api.github.com/users/xhad1234/repos","events_url":"https://api.github.com/users/xhad1234/events{/privacy}","received_events_url":"https://api.github.com/users/xhad1234/received_events","type":"User","site_admin":false},"repo":{"id":58971312,"name":"alluxio","full_name":"xhad1234/alluxio","owner":{"login":"xhad1234","id":4424966,"avatar_url":"https://avatars.githubusercontent.com/u/4424966?v=3","gravatar_id":"","url":"https://api.github.com/users/xhad1234","html_url":"https://github.com/xhad1234","followers_url":"https://api.github.com/users/xhad1234/followers","following_url":"https://api.github.com/users/xhad1234/following{/other_user}","gists_url":"https://api.github.com/users/xhad1234/gists{/gist_id}","starred_url":"https://api.github.com/users/xhad1234/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xhad1234/subscriptions","organizations_url":"https://api.github.com/users/xhad1234/orgs","repos_url":"https://api.github.com/users/xhad1234/repos","events_url":"https://api.github.com/users/xhad1234/events{/privacy}","received_events_url":"https://api.github.com/users/xhad1234/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/xhad1234/alluxio","description":"Alluxio, formerly Tachyon, Memory Speed Virtual Distributed Storage System","fork":true,"url":"https://api.github.com/repos/xhad1234/alluxio","forks_url":"https://api.github.com/repos/xhad1234/alluxio/forks","keys_url":"https://api.github.com/repos/xhad1234/alluxio/keys{/key_id}","collaborators_url":"https://api.github.com/repos/xhad1234/alluxio/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/xhad1234/alluxio/teams","hooks_url":"https://api.github.com/repos/xhad1234/alluxio/hooks","issue_events_url":"https://api.github.com/repos/xhad1234/alluxio/issues/events{/number}","events_url":"https://api.github.com/repos/xhad1234/alluxio/events","assignees_url":"https://api.github.com/repos/xhad1234/alluxio/assignees{/user}","branches_url":"https://api.github.com/repos/xhad1234/alluxio/branches{/branch}","tags_url":"https://api.github.com/repos/xhad1234/alluxio/tags","blobs_url":"https://api.github.com/repos/xhad1234/alluxio/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/xhad1234/alluxio/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/xhad1234/alluxio/git/refs{/sha}","trees_url":"https://api.github.com/repos/xhad1234/alluxio/git/trees{/sha}","statuses_url":"https://api.github.com/repos/xhad1234/alluxio/statuses/{sha}","languages_url":"https://api.github.com/repos/xhad1234/alluxio/languages","stargazers_url":"https://api.github.com/repos/xhad1234/alluxio/stargazers","contributors_url":"https://api.github.com/repos/xhad1234/alluxio/contributors","subscribers_url":"https://api.github.com/repos/xhad1234/alluxio/subscribers","subscription_url":"https://api.github.com/repos/xhad1234/alluxio/subscription","commits_url":"https://api.github.com/repos/xhad1234/alluxio/commits{/sha}","git_commits_url":"https://api.github.com/repos/xhad1234/alluxio/git/commits{/sha}","comments_url":"https://api.github.com/repos/xhad1234/alluxio/comments{/number}","issue_comment_url":"https://api.github.com/repos/xhad1234/alluxio/issues/comments{/number}","contents_url":"https://api.github.com/repos/xhad1234/alluxio/contents/{+path}","compare_url":"https://api.github.com/repos/xhad1234/alluxio/compare/{base}...{head}","merges_url":"https://api.github.com/repos/xhad1234/alluxio/merges","archive_url":"https://api.github.com/repos/xhad1234/alluxio/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/xhad1234/alluxio/downloads","issues_url":"https://api.github.com/repos/xhad1234/alluxio/issues{/number}","pulls_url":"https://api.github.com/repos/xhad1234/alluxio/pulls{/number}","milestones_url":"https://api.github.com/repos/xhad1234/alluxio/milestones{/number}","notifications_url":"https://api.github.com/repos/xhad1234/alluxio/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/xhad1234/alluxio/labels{/name}","releases_url":"https://api.github.com/repos/xhad1234/alluxio/releases{/id}","deployments_url":"https://api.github.com/repos/xhad1234/alluxio/deployments","created_at":"2016-05-16T22:10:01Z","updated_at":"2016-05-16T22:10:06Z","pushed_at":"2016-05-18T18:25:27Z","git_url":"git://github.com/xhad1234/alluxio.git","ssh_url":"git@github.com:xhad1234/alluxio.git","clone_url":"https://github.com/xhad1234/alluxio.git","svn_url":"https://github.com/xhad1234/alluxio","homepage":"http://www.alluxio.org/","size":50820,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"Alluxio:master","ref":"master","sha":"f9cc9735b4d2729512214160cd1ce7ab026ec906","user":{"login":"Alluxio","id":16203694,"avatar_url":"https://avatars.githubusercontent.com/u/16203694?v=3","gravatar_id":"","url":"https://api.github.com/users/Alluxio","html_url":"https://github.com/Alluxio","followers_url":"https://api.github.com/users/Alluxio/followers","following_url":"https://api.github.com/users/Alluxio/following{/other_user}","gists_url":"https://api.github.com/users/Alluxio/gists{/gist_id}","starred_url":"https://api.github.com/users/Alluxio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Alluxio/subscriptions","organizations_url":"https://api.github.com/users/Alluxio/orgs","repos_url":"https://api.github.com/users/Alluxio/repos","events_url":"https://api.github.com/users/Alluxio/events{/privacy}","received_events_url":"https://api.github.com/users/Alluxio/received_events","type":"Organization","site_admin":false},"repo":{"id":7276954,"name":"alluxio","full_name":"Alluxio/alluxio","owner":{"login":"Alluxio","id":16203694,"avatar_url":"https://avatars.githubusercontent.com/u/16203694?v=3","gravatar_id":"","url":"https://api.github.com/users/Alluxio","html_url":"https://github.com/Alluxio","followers_url":"https://api.github.com/users/Alluxio/followers","following_url":"https://api.github.com/users/Alluxio/following{/other_user}","gists_url":"https://api.github.com/users/Alluxio/gists{/gist_id}","starred_url":"https://api.github.com/users/Alluxio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Alluxio/subscriptions","organizations_url":"https://api.github.com/users/Alluxio/orgs","repos_url":"https://api.github.com/users/Alluxio/repos","events_url":"https://api.github.com/users/Alluxio/events{/privacy}","received_events_url":"https://api.github.com/users/Alluxio/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Alluxio/alluxio","description":"Alluxio, formerly Tachyon, Memory Speed Virtual Distributed Storage System","fork":false,"url":"https://api.github.com/repos/Alluxio/alluxio","forks_url":"https://api.github.com/repos/Alluxio/alluxio/forks","keys_url":"https://api.github.com/repos/Alluxio/alluxio/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Alluxio/alluxio/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Alluxio/alluxio/teams","hooks_url":"https://api.github.com/repos/Alluxio/alluxio/hooks","issue_events_url":"https://api.github.com/repos/Alluxio/alluxio/issues/events{/number}","events_url":"https://api.github.com/repos/Alluxio/alluxio/events","assignees_url":"https://api.github.com/repos/Alluxio/alluxio/assignees{/user}","branches_url":"https://api.github.com/repos/Alluxio/alluxio/branches{/branch}","tags_url":"https://api.github.com/repos/Alluxio/alluxio/tags","blobs_url":"https://api.github.com/repos/Alluxio/alluxio/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Alluxio/alluxio/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Alluxio/alluxio/git/refs{/sha}","trees_url":"https://api.github.com/repos/Alluxio/alluxio/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Alluxio/alluxio/statuses/{sha}","languages_url":"https://api.github.com/repos/Alluxio/alluxio/languages","stargazers_url":"https://api.github.com/repos/Alluxio/alluxio/stargazers","contributors_url":"https://api.github.com/repos/Alluxio/alluxio/contributors","subscribers_url":"https://api.github.com/repos/Alluxio/alluxio/subscribers","subscription_url":"https://api.github.com/repos/Alluxio/alluxio/subscription","commits_url":"https://api.github.com/repos/Alluxio/alluxio/commits{/sha}","git_commits_url":"https://api.github.com/repos/Alluxio/alluxio/git/commits{/sha}","comments_url":"https://api.github.com/repos/Alluxio/alluxio/comments{/number}","issue_comment_url":"https://api.github.com/repos/Alluxio/alluxio/issues/comments{/number}","contents_url":"https://api.github.com/repos/Alluxio/alluxio/contents/{+path}","compare_url":"https://api.github.com/repos/Alluxio/alluxio/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Alluxio/alluxio/merges","archive_url":"https://api.github.com/repos/Alluxio/alluxio/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Alluxio/alluxio/downloads","issues_url":"https://api.github.com/repos/Alluxio/alluxio/issues{/number}","pulls_url":"https://api.github.com/repos/Alluxio/alluxio/pulls{/number}","milestones_url":"https://api.github.com/repos/Alluxio/alluxio/milestones{/number}","notifications_url":"https://api.github.com/repos/Alluxio/alluxio/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Alluxio/alluxio/labels{/name}","releases_url":"https://api.github.com/repos/Alluxio/alluxio/releases{/id}","deployments_url":"https://api.github.com/repos/Alluxio/alluxio/deployments","created_at":"2012-12-21T17:43:46Z","updated_at":"2016-05-18T15:47:22Z","pushed_at":"2016-05-18T18:31:09Z","git_url":"git://github.com/Alluxio/alluxio.git","ssh_url":"git@github.com:Alluxio/alluxio.git","clone_url":"https://github.com/Alluxio/alluxio.git","svn_url":"https://github.com/Alluxio/alluxio","homepage":"http://www.alluxio.org/","size":82319,"stargazers_count":2344,"watchers_count":2344,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":927,"mirror_url":null,"open_issues_count":20,"forks":927,"open_issues":20,"watchers":2344,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Alluxio/alluxio/pulls/3298"},"html":{"href":"https://github.com/Alluxio/alluxio/pull/3298"},"issue":{"href":"https://api.github.com/repos/Alluxio/alluxio/issues/3298"},"comments":{"href":"https://api.github.com/repos/Alluxio/alluxio/issues/3298/comments"},"review_comments":{"href":"https://api.github.com/repos/Alluxio/alluxio/pulls/3298/comments"},"review_comment":{"href":"https://api.github.com/repos/Alluxio/alluxio/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Alluxio/alluxio/pulls/3298/commits"},"statuses":{"href":"https://api.github.com/repos/Alluxio/alluxio/statuses/3837f73b36ce230f049e4a71f192aa35467be49c"}}}}