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
2becec3e
Commit
2becec3e
authored
Feb 28, 2016
by
Johannes Edmeier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add tests for NotifierConfiguration
parent
79c850ac
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
94 additions
and
0 deletions
+94
-0
NotifierConfigurationTest.java
...ecentric/boot/admin/config/NotifierConfigurationTest.java
+94
-0
No files found.
spring-boot-admin-server/src/test/java/de/codecentric/boot/admin/config/NotifierConfigurationTest.java
0 → 100644
View file @
2becec3e
/*
* Copyright 2014 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
de
.
codecentric
.
boot
.
admin
.
config
;
import
static
org
.
hamcrest
.
CoreMatchers
.
is
;
import
static
org
.
hamcrest
.
Matchers
.
empty
;
import
static
org
.
junit
.
Assert
.
assertThat
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.List
;
import
org.junit.After
;
import
org.junit.Test
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.web.context.support.AnnotationConfigWebApplicationContext
;
import
de.codecentric.boot.admin.event.ClientApplicationEvent
;
import
de.codecentric.boot.admin.event.ClientApplicationStatusChangedEvent
;
import
de.codecentric.boot.admin.model.Application
;
import
de.codecentric.boot.admin.model.StatusInfo
;
import
de.codecentric.boot.admin.notify.Notifier
;
public
class
NotifierConfigurationTest
{
private
static
final
ClientApplicationEvent
APP_DOWN
=
new
ClientApplicationStatusChangedEvent
(
Application
.
create
(
"App"
).
withId
(
"id-1"
).
withHealthUrl
(
"http://health"
)
.
withStatusInfo
(
StatusInfo
.
ofDown
()).
build
(),
StatusInfo
.
ofUp
(),
StatusInfo
.
ofDown
());
private
AnnotationConfigWebApplicationContext
context
;
@After
public
void
close
()
{
if
(
this
.
context
!=
null
)
{
this
.
context
.
close
();
}
}
@Test
public
void
test_notifierListener
()
{
load
(
TestNotifierConfig
.
class
);
context
.
publishEvent
(
APP_DOWN
);
assertThat
(
context
.
getBean
(
TestNotifier
.
class
).
getEvents
(),
is
(
Arrays
.
asList
(
APP_DOWN
)));
}
@Test
public
void
test_no_notifierListener
()
{
load
(
null
);
assertThat
(
context
.
getBeansOfType
(
Notifier
.
class
).
values
(),
empty
());
}
private
void
load
(
Class
<?>
config
)
{
context
=
new
AnnotationConfigWebApplicationContext
();
if
(
config
!=
null
)
{
context
.
register
(
config
);
}
context
.
register
(
NotifierConfiguration
.
class
);
context
.
refresh
();
}
public
static
class
TestNotifierConfig
{
@Bean
public
Notifier
testNotifier
()
{
return
new
TestNotifier
();
}
}
private
static
class
TestNotifier
implements
Notifier
{
private
List
<
ClientApplicationEvent
>
events
=
new
ArrayList
<
ClientApplicationEvent
>();
@Override
public
void
notify
(
ClientApplicationEvent
event
)
{
this
.
events
.
add
(
event
);
}
public
List
<
ClientApplicationEvent
>
getEvents
()
{
return
events
;
}
}
}
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