Activate surefire plugin and remove unnecessary configuration

This commit is contained in:
Manu Zi 2019-04-01 21:17:35 +02:00
parent 1f5a9eff6d
commit 1ae0e8d994
3 changed files with 16 additions and 53 deletions

22
pom.xml
View File

@ -22,11 +22,10 @@
<junit.jupiter.version>5.3.2</junit.jupiter.version> <junit.jupiter.version>5.3.2</junit.jupiter.version>
<docker-maven-plugin.version>0.27.2</docker-maven-plugin.version> <docker-maven-plugin.version>0.27.2</docker-maven-plugin.version>
<jgitflow-maven-plugin.version>1.0-m5.1</jgitflow-maven-plugin.version> <jgitflow-maven-plugin.version>1.0-m5.1</jgitflow-maven-plugin.version>
<spring-boot-starter.version>2.1.1.RELEASE</spring-boot-starter.version> <spring-boot.version>2.1.3.RELEASE</spring-boot.version>
<spring.kafka.version>2.2.4.RELEASE</spring.kafka.version> <spring.kafka.version>2.2.4.RELEASE</spring.kafka.version>
<maven-surefire-plugin.version>2.22.1</maven-surefire-plugin.version> <maven-surefire-plugin.version>2.22.1</maven-surefire-plugin.version>
<maven-failsafe-plugin.version>2.22.1</maven-failsafe-plugin.version>
<assertj-core.version>3.11.1</assertj-core.version> <assertj-core.version>3.11.1</assertj-core.version>
<guava.version>27.1-jre</guava.version> <guava.version>27.1-jre</guava.version>
</properties> </properties>
@ -35,7 +34,7 @@
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId> <artifactId>spring-boot-starter-actuator</artifactId>
<version>${spring-boot-starter.version}</version> <version>${spring-boot.version}</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
@ -77,7 +76,7 @@
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-test</artifactId> <artifactId>spring-boot-test</artifactId>
<version>2.1.2.RELEASE</version> <version>${spring-boot.version}</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
@ -102,6 +101,10 @@
</execution> </execution>
</executions> </executions>
</plugin> </plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire-plugin.version}</version>
</plugin>
<plugin> <plugin>
<groupId>external.atlassian.jgitflow</groupId> <groupId>external.atlassian.jgitflow</groupId>
<artifactId>jgitflow-maven-plugin</artifactId> <artifactId>jgitflow-maven-plugin</artifactId>
@ -138,15 +141,4 @@
</pluginManagement> </pluginManagement>
</build> </build>
<distributionManagement>
<repository>
<id>releases</id>
<url>http://nexus.device-insight.de/nexus/content/repositories/releases</url>
</repository>
<snapshotRepository>
<id>snapshots</id>
<url>http://nexus.device-insight.de/nexus/content/repositories/snapshots</url>
</snapshotRepository>
</distributionManagement>
</project> </project>

View File

@ -1,28 +0,0 @@
spring:
jackson:
serialization:
write-dates-as-timestamps: false
management:
server:
port: 9090
metrics:
export:
prometheus:
enabled: true
endpoints:
web:
exposure:
include:
- health
- info
- prometheus
- loggers
- httptrace
- configprops
- metrics
- heapdump
- threaddump
endpoint:
health:
show-details: always

View File

@ -6,10 +6,7 @@ import static org.assertj.core.api.Assertions.assertThat;
import kafka.server.KafkaServer; import kafka.server.KafkaServer;
import org.apache.kafka.clients.consumer.Consumer; import org.apache.kafka.clients.consumer.Consumer;
import org.apache.kafka.common.serialization.StringDeserializer; import org.apache.kafka.common.serialization.StringDeserializer;
import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.*;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInstance;
import org.junit.jupiter.api.extension.ExtendWith; import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.actuate.health.Health; import org.springframework.boot.actuate.health.Health;
@ -29,7 +26,6 @@ import java.util.Map;
@ExtendWith(SpringExtension.class) @ExtendWith(SpringExtension.class)
@EmbeddedKafka(topics = {TOPIC}) @EmbeddedKafka(topics = {TOPIC})
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
public class KafkaConsumingHealthIndicatorTest { public class KafkaConsumingHealthIndicatorTest {
static final String TOPIC = "health-checks"; static final String TOPIC = "health-checks";
@ -39,7 +35,7 @@ public class KafkaConsumingHealthIndicatorTest {
@Autowired @Autowired
private EmbeddedKafkaBroker embeddedKafkaBroker; private EmbeddedKafkaBroker embeddedKafkaBroker;
@BeforeAll @BeforeEach
public void setUp() { public void setUp() {
Map<String, Object> consumerConfigs = Map<String, Object> consumerConfigs =
new HashMap<>(KafkaTestUtils.consumerProps("consumer", "false", embeddedKafkaBroker)); new HashMap<>(KafkaTestUtils.consumerProps("consumer", "false", embeddedKafkaBroker));
@ -49,7 +45,7 @@ public class KafkaConsumingHealthIndicatorTest {
consumer.poll(Duration.ofSeconds(1)); consumer.poll(Duration.ofSeconds(1));
} }
@AfterAll @AfterEach
public void tearDown() { public void tearDown() {
consumer.close(); consumer.close();
embeddedKafkaBroker.getKafkaServers().forEach(KafkaServer::shutdown); embeddedKafkaBroker.getKafkaServers().forEach(KafkaServer::shutdown);
@ -58,14 +54,14 @@ public class KafkaConsumingHealthIndicatorTest {
@Test @Test
public void kafkaIsDown() throws Exception { public void kafkaIsDown() throws Exception {
KafkaHealthProperties kafkaHealthProperties = new KafkaHealthProperties(); final KafkaHealthProperties kafkaHealthProperties = new KafkaHealthProperties();
kafkaHealthProperties.setTopic(TOPIC); kafkaHealthProperties.setTopic(TOPIC);
final KafkaProperties kafkaProperties = new KafkaProperties(); final KafkaProperties kafkaProperties = new KafkaProperties();
BrokerAddress[] brokerAddresses = embeddedKafkaBroker.getBrokerAddresses(); final BrokerAddress[] brokerAddresses = embeddedKafkaBroker.getBrokerAddresses();
kafkaProperties.setBootstrapServers(Collections.singletonList(brokerAddresses[0].toString())); kafkaProperties.setBootstrapServers(Collections.singletonList(brokerAddresses[0].toString()));
KafkaConsumingHealthIndicator healthIndicator = final KafkaConsumingHealthIndicator healthIndicator =
new KafkaConsumingHealthIndicator(kafkaHealthProperties, kafkaProperties.buildConsumerProperties(), new KafkaConsumingHealthIndicator(kafkaHealthProperties, kafkaProperties.buildConsumerProperties(),
kafkaProperties.buildProducerProperties()); kafkaProperties.buildProducerProperties());
healthIndicator.subscribeToTopic(); healthIndicator.subscribeToTopic();
@ -74,6 +70,9 @@ public class KafkaConsumingHealthIndicatorTest {
assertThat(health.getStatus()).isEqualTo(Status.UP); assertThat(health.getStatus()).isEqualTo(Status.UP);
shutdownKafka(); shutdownKafka();
health = healthIndicator.health();
assertThat(health.getStatus()).isEqualTo(Status.DOWN);
} }
private void shutdownKafka() { private void shutdownKafka() {