-
Notifications
You must be signed in to change notification settings - Fork 0
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
3a90158
commit 0fbf1e0
Showing
2 changed files
with
144 additions
and
20 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
52 changes: 52 additions & 0 deletions
52
src/test/java/com/osiris/betterthread/BetterThreadDisplayerTest.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,52 @@ | ||
package com.osiris.betterthread; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
class BetterThreadDisplayerTest { | ||
|
||
@Test | ||
void test() { | ||
BetterThreadManager manager = new BetterThreadManager(); | ||
BetterThread test1 = new BetterThread(manager); | ||
test1.start(); | ||
BetterThread test2 = new BetterThread(manager); | ||
test2.start(); | ||
BetterThread test3 = new BetterThread(manager); | ||
test3.start(); | ||
BetterThreadDisplayer displayer = new BetterThreadDisplayer(manager); | ||
displayer.start(); | ||
|
||
// Its normal to get values over 100% because of this loop | ||
Thread thread = new Thread(()->{ | ||
try { | ||
while (!displayer.isFinished()) | ||
for (BetterThread t : | ||
manager.getAll()) { | ||
t.step(); | ||
Thread.sleep(10); | ||
} | ||
} catch (InterruptedException e) { | ||
e.printStackTrace(); | ||
} | ||
}); | ||
thread.start(); | ||
|
||
try{ | ||
while (!displayer.isFinished()) | ||
Thread.sleep(1000); | ||
boolean isWarning = false; | ||
for (BetterThread t : | ||
manager.getAll()) { | ||
if (!t.getBetterWarnings().isEmpty()) | ||
isWarning = true; | ||
} | ||
assertTrue(!isWarning); | ||
} catch (Exception e) { | ||
e.printStackTrace(); | ||
} | ||
|
||
|
||
} | ||
} |