Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests for the client & server autoconfig and fix issue with cycli…
…c dependency
- Loading branch information
Johannes Stelzer
committed
Mar 18, 2015
1 parent
d370971
commit 66173f5
Showing
7 changed files
with
146 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
...erver/src/test/java/de/codecentric/boot/admin/config/AdminServerWebConfigurationTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package de.codecentric.boot.admin.config; | ||
|
||
import static org.junit.Assert.assertTrue; | ||
|
||
import org.junit.After; | ||
import org.junit.Test; | ||
import org.springframework.boot.autoconfigure.web.ServerPropertiesAutoConfiguration; | ||
import org.springframework.boot.test.EnvironmentTestUtils; | ||
import org.springframework.cloud.client.discovery.noop.NoopDiscoveryClientAutoConfiguration; | ||
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext; | ||
|
||
import de.codecentric.boot.admin.discovery.ApplicationDiscoveryListener; | ||
import de.codecentric.boot.admin.registry.store.ApplicationStore; | ||
import de.codecentric.boot.admin.registry.store.HazelcastApplicationStore; | ||
import de.codecentric.boot.admin.registry.store.SimpleApplicationStore; | ||
|
||
public class AdminServerWebConfigurationTest { | ||
|
||
private AnnotationConfigWebApplicationContext context; | ||
|
||
@After | ||
public void close() { | ||
if (this.context != null) { | ||
this.context.close(); | ||
} | ||
} | ||
|
||
@Test | ||
public void simpleConfig() { | ||
load("spring.boot.admin.hazelcast.enabled:false", "spring.boot.admin.discovery.enabled:false"); | ||
assertTrue(context.getBean(ApplicationStore.class) instanceof SimpleApplicationStore); | ||
assertTrue(context.getBeansOfType(ApplicationDiscoveryListener.class).isEmpty()); | ||
} | ||
|
||
@Test | ||
public void hazelcastConfig() { | ||
load("spring.boot.admin.hazelcast.enabled:true", "spring.boot.admin.discovery.enabled:false"); | ||
assertTrue(context.getBean(ApplicationStore.class) instanceof HazelcastApplicationStore); | ||
assertTrue(context.getBeansOfType(ApplicationDiscoveryListener.class).isEmpty()); | ||
} | ||
|
||
@Test | ||
public void discoveryConfig() { | ||
load("spring.boot.admin.hazelcast.enabled:false", "spring.boot.admin.discovery.enabled:true"); | ||
assertTrue(context.getBean(ApplicationStore.class) instanceof SimpleApplicationStore); | ||
context.getBean(ApplicationDiscoveryListener.class); | ||
} | ||
|
||
|
||
private void load(String... environment) { | ||
AnnotationConfigWebApplicationContext applicationContext = new AnnotationConfigWebApplicationContext(); | ||
applicationContext.register(ServerPropertiesAutoConfiguration.class); | ||
applicationContext.register(NoopDiscoveryClientAutoConfiguration.class); | ||
applicationContext.register(AdminServerWebConfiguration.class); | ||
EnvironmentTestUtils.addEnvironment(applicationContext, environment); | ||
applicationContext.refresh(); | ||
this.context = applicationContext; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
...est/java/de/codecentric/boot/admin/config/SpringBootAdminClientAutoConfigurationTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package de.codecentric.boot.admin.config; | ||
|
||
import static org.junit.Assert.assertTrue; | ||
|
||
import org.junit.After; | ||
import org.junit.Test; | ||
import org.springframework.boot.autoconfigure.web.ServerPropertiesAutoConfiguration; | ||
import org.springframework.boot.test.EnvironmentTestUtils; | ||
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext; | ||
|
||
import de.codecentric.boot.admin.actuate.LogfileMvcEndpoint; | ||
import de.codecentric.boot.admin.services.SpringBootAdminRegistrator; | ||
|
||
public class SpringBootAdminClientAutoConfigurationTest { | ||
|
||
private AnnotationConfigWebApplicationContext context; | ||
|
||
@After | ||
public void close() { | ||
if (this.context != null) { | ||
this.context.close(); | ||
} | ||
} | ||
|
||
@Test | ||
public void not_active() { | ||
load(); | ||
assertTrue(context.getBeansOfType(SpringBootAdminRegistrator.class).isEmpty()); | ||
} | ||
|
||
@Test | ||
public void active_nologfile() { | ||
load("spring.boot.admin.url:http://localhost:8081"); | ||
context.getBean(SpringBootAdminRegistrator.class); | ||
assertTrue(context.getBeansOfType(LogfileMvcEndpoint.class).isEmpty()); | ||
} | ||
|
||
@Test | ||
public void active_logfile() { | ||
load("spring.boot.admin.url:http://localhost:8081", "logging.file:spring.log"); | ||
context.getBean(LogfileMvcEndpoint.class); | ||
context.getBean(SpringBootAdminRegistrator.class); | ||
} | ||
|
||
@Test | ||
public void active_logfile_supressed() { | ||
load("spring.boot.admin.url:http://localhost:8081", "logging.file:spring.log", | ||
"endpoints.logfile.enabled:false"); | ||
context.getBean(SpringBootAdminRegistrator.class); | ||
assertTrue(context.getBeansOfType(LogfileMvcEndpoint.class).isEmpty()); | ||
} | ||
|
||
private void load(String... environment) { | ||
AnnotationConfigWebApplicationContext applicationContext = new AnnotationConfigWebApplicationContext(); | ||
applicationContext.register(ServerPropertiesAutoConfiguration.class); | ||
applicationContext.register(SpringBootAdminClientAutoConfiguration.class); | ||
EnvironmentTestUtils.addEnvironment(applicationContext, environment); | ||
applicationContext.refresh(); | ||
this.context = applicationContext; | ||
} | ||
|
||
} |