File tree Expand file tree Collapse file tree 1 file changed +14
-6
lines changed
unirest-bdd-tests/src/test/java/BehaviorTests Expand file tree Collapse file tree 1 file changed +14
-6
lines changed Original file line number Diff line number Diff line change 2727
2828
2929import kong .unirest .core .SseRequest ;
30+ import org .junit .jupiter .api .AfterEach ;
3031import org .junit .jupiter .api .BeforeEach ;
3132import org .junit .jupiter .api .Test ;
3233
3334import java .util .List ;
3435import java .util .Map ;
35- import java .util .function .Supplier ;
36+ import java .util .concurrent .ExecutorService ;
37+ import java .util .concurrent .Executors ;
3638
3739import static kong .unirest .core .Unirest .sse ;
38- import static org .assertj .core .api .Assertions .assertThat ;
39- import static org .junit .jupiter .api .Assertions .assertTrue ;
4040
4141public class SSETest extends BddTest {
4242
4343 TestListener listener ;
44+ ExecutorService pool ;
4445
4546 @ BeforeEach
4647 public void setUp () {
4748 super .setUp ();
4849 listener = new TestListener ();
50+ pool = Executors .newFixedThreadPool (1 );
51+ }
52+
53+ @ AfterEach
54+ @ Override
55+ public void tearDown () {
56+ super .tearDown ();
57+ pool .shutdown ();
4958 }
5059
5160 @ Test
@@ -120,15 +129,14 @@ void canReplaceTheDefaultAcceptsHeader(){
120129 .assertHeader ("Accept" , "application/json" );
121130 }
122131
123- private static void runWith (SseRequest sse , TestListener tl ) {
132+ private void runWith (SseRequest sse , TestListener tl ) {
124133 try {
125- var t = new Thread (() -> {
134+ var t = pool . submit (() -> {
126135 var future = sse .connect (tl );
127136 while (!future .isDone ()){
128137 // waitin'
129138 }
130139 });
131- t .start ();
132140
133141 Thread .sleep (1000 );
134142 }catch (Exception e ){
You can’t perform that action at this time.
0 commit comments