-
Notifications
You must be signed in to change notification settings - Fork 461
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e95d651
commit abfc8a9
Showing
2 changed files
with
39 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
dotCMS/src/integration-test/java/com/dotcms/util/ThreadUtilsTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package com.dotcms.util; | ||
|
||
|
||
import com.dotmarketing.util.ThreadUtils; | ||
import graphql.Assert; | ||
import org.junit.Test; | ||
|
||
public class ThreadUtilsTest { | ||
|
||
@Test | ||
public void Test_Get_Thread_Compare_With_Current_Thread() { | ||
final Thread currentThread = Thread.currentThread(); | ||
final Thread byNameThread = ThreadUtils.getThread(currentThread.getName()); | ||
assert currentThread == byNameThread; | ||
} | ||
|
||
@Test | ||
public void Test_Get_Thread_Non_Existing_Thread_Name() { | ||
final Thread byNameThread = ThreadUtils.getThread("NonExistingThreadName"); | ||
Assert.assertNull(byNameThread); | ||
} | ||
|
||
@Test | ||
public void Test_Get_Thread_When_Null_Is_Passed() { | ||
final Thread byNameThread = ThreadUtils.getThread(null); | ||
Assert.assertNull(byNameThread); | ||
} | ||
|
||
@Test | ||
public void Test_Sleep() { | ||
final long t1 = System.currentTimeMillis(); | ||
ThreadUtils.sleep(100L); | ||
final long t2 = System.currentTimeMillis(); | ||
assert t2 - t1 >= 100L; | ||
} | ||
|
||
} |