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
3858c629
Commit
3858c629
authored
Jun 14, 2021
by
Andy Wilkinson
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '2.4.x' into 2.5.x
Closes gh-26886
parents
d0b8741f
7a14a532
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
8 deletions
+24
-8
TunnelClientTests.java
...mework/boot/devtools/tunnel/client/TunnelClientTests.java
+24
-8
No files found.
spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/tunnel/client/TunnelClientTests.java
View file @
3858c629
...
...
@@ -25,15 +25,13 @@ import java.nio.channels.Channels;
import
java.nio.channels.SocketChannel
;
import
java.nio.channels.WritableByteChannel
;
import
java.time.Duration
;
import
java.util.concurrent.atomic.AtomicInteger
;
import
org.awaitility.Awaitility
;
import
org.junit.jupiter.api.Test
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThatIllegalArgumentException
;
import
static
org
.
mockito
.
ArgumentMatchers
.
any
;
import
static
org
.
mockito
.
Mockito
.
mock
;
import
static
org
.
mockito
.
Mockito
.
verify
;
/**
* Tests for {@link TunnelClient}.
...
...
@@ -98,16 +96,34 @@ class TunnelClientTests {
@Test
void
addListener
()
throws
Exception
{
TunnelClient
client
=
new
TunnelClient
(
0
,
this
.
tunnelConnection
);
TunnelClientListener
listener
=
mock
(
TunnelClientListener
.
class
);
MockTunnelClientListener
listener
=
new
MockTunnelClientListener
(
);
client
.
addListener
(
listener
);
int
port
=
client
.
start
();
SocketChannel
channel
=
SocketChannel
.
open
(
new
InetSocketAddress
(
port
));
Thread
.
sleep
(
200
);
channel
.
close
(
);
Awaitility
.
await
().
atMost
(
Duration
.
ofSeconds
(
30
)).
until
(
listener
.
onOpen
::
get
,
(
open
)
->
open
==
1
);
assertThat
(
listener
.
onClose
).
hasValue
(
0
);
client
.
getServerThread
().
stopAcceptingConnections
();
channel
.
close
();
Awaitility
.
await
().
atMost
(
Duration
.
ofSeconds
(
30
)).
until
(
listener
.
onClose
::
get
,
(
close
)
->
close
==
1
);
client
.
getServerThread
().
join
(
2000
);
verify
(
listener
).
onOpen
(
any
(
SocketChannel
.
class
));
verify
(
listener
).
onClose
(
any
(
SocketChannel
.
class
));
}
static
class
MockTunnelClientListener
implements
TunnelClientListener
{
private
final
AtomicInteger
onOpen
=
new
AtomicInteger
();
private
final
AtomicInteger
onClose
=
new
AtomicInteger
();
@Override
public
void
onOpen
(
SocketChannel
socket
)
{
this
.
onOpen
.
incrementAndGet
();
}
@Override
public
void
onClose
(
SocketChannel
socket
)
{
this
.
onClose
.
incrementAndGet
();
}
}
static
class
MockTunnelConnection
implements
TunnelConnection
{
...
...
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