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
8b7c58c0
Commit
8b7c58c0
authored
Aug 28, 2017
by
Johannes Edmeier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Assert instances synchronized events via hazelcast in tests
parent
76df8b0a
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
49 additions
and
14 deletions
+49
-14
AdminServerWebConfiguration.java
...boot/admin/server/config/AdminServerWebConfiguration.java
+1
-5
AdminApplicationHazelcastTest.java
...tric/boot/admin/server/AdminApplicationHazelcastTest.java
+40
-1
AdminServerWebConfigurationTest.java
.../admin/server/config/AdminServerWebConfigurationTest.java
+8
-8
No files found.
spring-boot-admin-server/src/main/java/de/codecentric/boot/admin/server/config/AdminServerWebConfiguration.java
View file @
8b7c58c0
...
...
@@ -26,7 +26,6 @@ import java.util.Map;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean
;
import
org.springframework.context.ApplicationContext
;
import
org.springframework.context.ApplicationContextAware
;
import
org.springframework.context.ApplicationEventPublisher
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.http.converter.HttpMessageConverter
;
...
...
@@ -37,13 +36,10 @@ import com.fasterxml.jackson.databind.ObjectMapper;
@Configuration
public
class
AdminServerWebConfiguration
implements
WebMvcConfigurer
,
ApplicationContextAware
{
private
final
ApplicationEventPublisher
publisher
;
private
final
AdminServerProperties
adminServerProperties
;
private
ApplicationContext
applicationContext
;
public
AdminServerWebConfiguration
(
ApplicationEventPublisher
publisher
,
AdminServerProperties
adminServerProperties
)
{
this
.
publisher
=
publisher
;
public
AdminServerWebConfiguration
(
AdminServerProperties
adminServerProperties
)
{
this
.
adminServerProperties
=
adminServerProperties
;
}
...
...
spring-boot-admin-server/src/test/java/de/codecentric/boot/admin/server/AdminApplicationHazelcastTest.java
View file @
8b7c58c0
...
...
@@ -16,14 +16,20 @@
package
de
.
codecentric
.
boot
.
admin
.
server
;
import
de.codecentric.boot.admin.server.config.EnableAdminServer
;
import
reactor.core.publisher.Mono
;
import
reactor.test.StepVerifier
;
import
java.util.stream.Collectors
;
import
org.junit.After
;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.SpringBootConfiguration
;
import
org.springframework.boot.autoconfigure.EnableAutoConfiguration
;
import
org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.http.MediaType
;
import
org.springframework.test.web.reactive.server.WebTestClient
;
import
com.hazelcast.config.Config
;
import
com.hazelcast.config.EvictionPolicy
;
import
com.hazelcast.config.InMemoryFormat
;
...
...
@@ -31,6 +37,7 @@ import com.hazelcast.config.MapConfig;
import
com.hazelcast.config.TcpIpConfig
;
import
static
java
.
util
.
Collections
.
singletonList
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
/**
* Integration test to verify the correct functionality of the REST API with Hazelcast
...
...
@@ -40,6 +47,7 @@ import static java.util.Collections.singletonList;
public
class
AdminApplicationHazelcastTest
extends
AbstractAdminApplicationTest
{
private
ServletWebServerApplicationContext
instance1
;
private
ServletWebServerApplicationContext
instance2
;
private
WebTestClient
webClient2
;
@Before
public
void
setUp
()
throws
Exception
{
...
...
@@ -52,6 +60,38 @@ public class AdminApplicationHazelcastTest extends AbstractAdminApplicationTest
"--management.security.enabled=false"
,
"--info.test=foobar"
);
super
.
setUp
(
instance1
.
getWebServer
().
getPort
());
this
.
webClient2
=
createWebClient
(
instance2
.
getWebServer
().
getPort
());
}
@Test
@Override
public
void
lifecycle
()
{
super
.
lifecycle
();
Mono
<
String
>
events1
=
getWebClient
().
get
()
.
uri
(
"/api/applications/events"
)
.
accept
(
MediaType
.
APPLICATION_JSON
)
.
exchange
()
.
expectStatus
()
.
isOk
()
.
returnResult
(
String
.
class
)
.
getResponseBody
()
.
collect
(
Collectors
.
joining
());
Mono
<
String
>
events2
=
webClient2
.
get
()
.
uri
(
"/api/applications/events"
)
.
accept
(
MediaType
.
APPLICATION_JSON
)
.
exchange
()
.
expectStatus
()
.
isOk
()
.
returnResult
(
String
.
class
)
.
getResponseBody
()
.
collect
(
Collectors
.
joining
());
StepVerifier
.
create
(
events1
.
and
(
events2
))
.
assertNext
(
t
->
assertThat
(
t
.
getT1
()).
isEqualTo
(
t
.
getT2
()))
.
verifyComplete
();
}
@After
...
...
@@ -67,7 +107,6 @@ public class AdminApplicationHazelcastTest extends AbstractAdminApplicationTest
@Bean
public
Config
hazelcastConfig
()
{
Config
config
=
new
Config
();
config
.
addMapConfig
(
new
MapConfig
(
"spring-boot-admin-event-store"
).
setInMemoryFormat
(
InMemoryFormat
.
OBJECT
)
.
setBackupCount
(
1
)
.
setEvictionPolicy
(
EvictionPolicy
.
NONE
));
...
...
spring-boot-admin-server/src/test/java/de/codecentric/boot/admin/server/config/AdminServerWebConfigurationTest.java
View file @
8b7c58c0
...
...
@@ -15,6 +15,7 @@
*/
package
de
.
codecentric
.
boot
.
admin
.
server
.
config
;
import
de.codecentric.boot.admin.server.discovery.ApplicationDiscoveryListener
;
import
de.codecentric.boot.admin.server.domain.entities.ApplicationRepository
;
import
de.codecentric.boot.admin.server.domain.entities.EventSourcingApplicationRepository
;
import
de.codecentric.boot.admin.server.eventstore.ClientApplicationEventStore
;
...
...
@@ -29,6 +30,7 @@ import org.junit.Test;
import
org.springframework.boot.autoconfigure.hazelcast.HazelcastAutoConfiguration
;
import
org.springframework.boot.autoconfigure.web.client.RestTemplateAutoConfiguration
;
import
org.springframework.boot.test.util.TestPropertyValues
;
import
org.springframework.cloud.client.discovery.simple.SimpleDiscoveryClientAutoConfiguration
;
import
org.springframework.cloud.commons.util.UtilAutoConfiguration
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
...
...
@@ -52,7 +54,7 @@ public class AdminServerWebConfigurationTest {
@Test
public
void
jacksonMapperPresentFromDefault
()
{
AdminServerWebConfiguration
config
=
new
AdminServerWebConfiguration
(
null
,
null
);
AdminServerWebConfiguration
config
=
new
AdminServerWebConfiguration
(
null
);
List
<
HttpMessageConverter
<?>>
converters
=
new
ArrayList
<>();
converters
.
add
(
new
MappingJackson2HttpMessageConverter
());
...
...
@@ -65,7 +67,7 @@ public class AdminServerWebConfigurationTest {
@Test
public
void
jacksonMapperPresentNeedExtend
()
{
AdminServerWebConfiguration
config
=
new
AdminServerWebConfiguration
(
null
,
null
);
AdminServerWebConfiguration
config
=
new
AdminServerWebConfiguration
(
null
);
List
<
HttpMessageConverter
<?>>
converters
=
new
ArrayList
<>();
config
.
extendMessageConverters
(
converters
);
...
...
@@ -89,14 +91,12 @@ public class AdminServerWebConfigurationTest {
assertThat
(
context
.
getBean
(
ClientApplicationEventStore
.
class
)).
isInstanceOf
(
HazelcastEventStore
.
class
);
}
//TODO
/*@Test
@Test
public
void
discoveryConfig
()
{
load(NoopDiscoveryClientAutoConfiguration.class);
assertThat(context.getBean(ApplicationRepository.class))
.isInstanceOf(EventSourcingApplicationRepository.class);
load
(
SimpleDiscoveryClientAutoConfiguration
.
class
);
assertThat
(
context
.
getBean
(
ApplicationRepository
.
class
)).
isInstanceOf
(
EventSourcingApplicationRepository
.
class
);
context
.
getBean
(
ApplicationDiscoveryListener
.
class
);
}*/
}
@Configuration
static
class
TestHazelcastConfig
{
...
...
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