Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
spring-boot-admin
Project
Overview
Details
Activity
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
openSource
spring-boot-admin
Commits
5bb3d178
Commit
5bb3d178
authored
Mar 12, 2018
by
Johannes Edmeier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix unstable tests
parent
38452e45
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
16 deletions
+28
-16
AdminServerNotifierAutoConfigurationTest.java
...rver/config/AdminServerNotifierAutoConfigurationTest.java
+28
-16
No files found.
spring-boot-admin-server/src/test/java/de/codecentric/boot/admin/server/config/AdminServerNotifierAutoConfigurationTest.java
View file @
5bb3d178
...
...
@@ -32,14 +32,16 @@ import de.codecentric.boot.admin.server.notify.OpsGenieNotifier;
import
de.codecentric.boot.admin.server.notify.PagerdutyNotifier
;
import
de.codecentric.boot.admin.server.notify.SlackNotifier
;
import
de.codecentric.boot.admin.server.notify.TelegramNotifier
;
import
reactor.core.publisher.Flux
;
import
reactor.core.publisher.FluxSink
;
import
reactor.core.publisher.Mono
;
import
reactor.core.publisher.UnicastProcessor
;
import
reactor.test.StepVerifier
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.List
;
import
org.junit.After
;
import
org.junit.Test
;
import
org.springframework.beans.factory.annotation.Qualifier
;
import
org.springframework.boot.autoconfigure.web.client.RestTemplateAutoConfiguration
;
import
org.springframework.boot.test.util.TestPropertyValues
;
import
org.springframework.context.annotation.AnnotationConfigApplicationContext
;
...
...
@@ -63,18 +65,16 @@ public class AdminServerNotifierAutoConfigurationTest {
}
@Test
public
void
test_notifierListener
()
throws
InterruptedException
{
public
void
test_notifierListener
()
{
load
(
TestSingleNotifierConfig
.
class
);
InstanceEventStore
store
=
context
.
getBean
(
InstanceEventStore
.
class
);
StepVerifier
.
create
(
store
)
StepVerifier
.
create
(
context
.
getBean
(
TestNotifier
.
class
).
getFlux
()
)
.
expectSubscription
()
.
then
(()
->
StepVerifier
.
create
(
store
.
append
(
Collections
.
singletonList
(
APP_DOWN
))).
verifyComplete
())
.
expectNext
(
APP_DOWN
)
.
thenCancel
()
.
verify
();
Thread
.
sleep
(
100
);
//wait for the notifications in different thread
assertThat
(
context
.
getBean
(
TestNotifier
.
class
).
getEvents
()).
containsOnly
(
APP_DOWN
);
}
@Test
...
...
@@ -161,7 +161,8 @@ public class AdminServerNotifierAutoConfigurationTest {
public
static
class
TestSingleNotifierConfig
{
@Bean
public
Notifier
testNotifier
()
{
@Qualifier
(
"testNotifier"
)
public
TestNotifier
testNotifier
()
{
return
new
TestNotifier
();
}
}
...
...
@@ -175,12 +176,14 @@ public class AdminServerNotifierAutoConfigurationTest {
private
static
class
TestMultipleNotifierConfig
{
@Bean
public
Notifier
testNotifier1
()
{
@Qualifier
(
"testNotifier1"
)
public
TestNotifier
testNotifier1
()
{
return
new
TestNotifier
();
}
@Bean
public
Notifier
testNotifier2
()
{
@Qualifier
(
"testNotifier2"
)
public
TestNotifier
testNotifier2
()
{
return
new
TestNotifier
();
}
}
...
...
@@ -188,27 +191,36 @@ public class AdminServerNotifierAutoConfigurationTest {
private
static
class
TestMultipleWithPrimaryNotifierConfig
{
@Bean
@Primary
public
Notifier
testNotifierPrimary
()
{
@Qualifier
(
"testNotifier"
)
public
TestNotifier
testNotifierPrimary
()
{
return
new
TestNotifier
();
}
@Bean
public
Notifier
testNotifier2
()
{
@Qualifier
(
"testNotifier3"
)
public
TestNotifier
testNotifier2
()
{
return
new
TestNotifier
();
}
}
private
static
class
TestNotifier
implements
Notifier
{
private
List
<
InstanceEvent
>
events
=
new
ArrayList
<>();
private
final
Flux
<
InstanceEvent
>
publishedFlux
;
private
final
FluxSink
<
InstanceEvent
>
sink
;
private
TestNotifier
()
{
UnicastProcessor
<
InstanceEvent
>
unicastProcessor
=
UnicastProcessor
.
create
();
this
.
publishedFlux
=
unicastProcessor
.
publish
().
autoConnect
(
0
);
this
.
sink
=
unicastProcessor
.
sink
();
}
@Override
public
Mono
<
Void
>
notify
(
InstanceEvent
event
)
{
this
.
events
.
add
(
event
);
return
null
;
this
.
sink
.
next
(
event
);
return
Mono
.
empty
()
;
}
public
List
<
InstanceEvent
>
getEvents
()
{
return
events
;
public
Flux
<
InstanceEvent
>
getFlux
()
{
return
publishedFlux
;
}
}
}
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