Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
c13385ea
Commit
c13385ea
authored
Jun 16, 2020
by
Tomek Szmytka
Committed by
Andy Wilkinson
Jun 19, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use Awaitility instead of Thread.sleep
See gh-21988
parent
67604a54
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
7 deletions
+6
-7
LiveReloadServerTests.java
...ework/boot/devtools/livereload/LiveReloadServerTests.java
+6
-7
No files found.
spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/livereload/LiveReloadServerTests.java
View file @
c13385ea
...
@@ -45,6 +45,7 @@ import org.springframework.web.socket.client.standard.StandardWebSocketClient;
...
@@ -45,6 +45,7 @@ import org.springframework.web.socket.client.standard.StandardWebSocketClient;
import
org.springframework.web.socket.handler.TextWebSocketHandler
;
import
org.springframework.web.socket.handler.TextWebSocketHandler
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
import
static
org
.
awaitility
.
Awaitility
.
await
;
import
static
org
.
hamcrest
.
Matchers
.
empty
;
import
static
org
.
hamcrest
.
Matchers
.
empty
;
import
static
org
.
hamcrest
.
Matchers
.
is
;
import
static
org
.
hamcrest
.
Matchers
.
is
;
import
static
org
.
hamcrest
.
Matchers
.
not
;
import
static
org
.
hamcrest
.
Matchers
.
not
;
...
@@ -88,17 +89,16 @@ class LiveReloadServerTests {
...
@@ -88,17 +89,16 @@ class LiveReloadServerTests {
void
triggerReload
()
throws
Exception
{
void
triggerReload
()
throws
Exception
{
LiveReloadWebSocketHandler
handler
=
connect
();
LiveReloadWebSocketHandler
handler
=
connect
();
this
.
server
.
triggerReload
();
this
.
server
.
triggerReload
();
Thread
.
sleep
(
200
);
await
().
atMost
(
Duration
.
ofSeconds
(
1
)).
until
(
handler:
:
getMessages
,
assertThat
(
handler
.
getMessages
().
get
(
0
)).
contains
(
"http://livereload.com/protocols/official-7"
);
(
msgs
)
->
msgs
.
get
(
0
).
contains
(
"http://livereload.com/protocols/official-7"
)
assertThat
(
handler
.
getMessages
().
get
(
1
)).
contains
(
"command\":\"reload\""
);
&&
msgs
.
get
(
1
).
contains
(
"command\":\"reload\""
)
);
}
}
@Test
@Test
void
pingPong
()
throws
Exception
{
void
pingPong
()
throws
Exception
{
LiveReloadWebSocketHandler
handler
=
connect
();
LiveReloadWebSocketHandler
handler
=
connect
();
handler
.
sendMessage
(
new
PingMessage
());
handler
.
sendMessage
(
new
PingMessage
());
Thread
.
sleep
(
200
);
await
().
atMost
(
Duration
.
ofSeconds
(
1
)).
until
(
handler:
:
getPongCount
,
is
(
1
));
assertThat
(
handler
.
getPongCount
()).
isEqualTo
(
1
);
}
}
@Test
@Test
...
@@ -117,8 +117,7 @@ class LiveReloadServerTests {
...
@@ -117,8 +117,7 @@ class LiveReloadServerTests {
void
serverClose
()
throws
Exception
{
void
serverClose
()
throws
Exception
{
LiveReloadWebSocketHandler
handler
=
connect
();
LiveReloadWebSocketHandler
handler
=
connect
();
this
.
server
.
stop
();
this
.
server
.
stop
();
Thread
.
sleep
(
200
);
await
().
atMost
(
Duration
.
ofSeconds
(
1
)).
until
(()
->
handler
.
getCloseStatus
().
getCode
(),
is
(
1006
));
assertThat
(
handler
.
getCloseStatus
().
getCode
()).
isEqualTo
(
1006
);
}
}
private
LiveReloadWebSocketHandler
connect
()
throws
Exception
{
private
LiveReloadWebSocketHandler
connect
()
throws
Exception
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment