added Spring Boot Actuator

pull/21/head
Niclas Thobaben 2022-02-15 13:53:57 +01:00
parent 195da6a64c
commit e46611f4ee
3 changed files with 65 additions and 1 deletions

38
pom.xml
View File

@ -44,7 +44,10 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
@ -82,6 +85,39 @@
</exclude>
</excludes>
</configuration>
<executions>
<execution>
<id>build-info</id>
<goals>
<goal>build-info</goal>
</goals>
</execution>
<execution>
<id>repackage</id>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>3.2.0</version>
<executions>
<execution>
<id>add-test-source</id>
<phase>generate-test-sources</phase>
<goals>
<goal>add-test-source</goal>
</goals>
<configuration>
<sources>
<source>src/integration/java</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

View File

@ -1,15 +1,39 @@
package de.nclazz.service.mailrelay;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.web.servlet.MockMvc;
import static org.springframework.http.MediaType.APPLICATION_JSON;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
@SpringBootTest
@AutoConfigureMockMvc
@ActiveProfiles("integration")
class MailRelayApplicationTest {
@Autowired
private MockMvc mockMvc;
@Test
public void contextLoads() {
}
@Test
void actuatorInfoIsAccessible() throws Exception {
mockMvc.perform(get("/actuator/info")
.contentType(APPLICATION_JSON))
.andExpect(status().isOk());
}
@Test
void actuatorHealthIsAccessible() throws Exception {
mockMvc.perform(get("/actuator/health")
.contentType(APPLICATION_JSON))
.andExpect(status().isOk());
}
}

View File

@ -2,4 +2,8 @@
spring.jpa.hibernate.ddl-auto=update
spring.datasource.url=jdbc:h2:file:./test-db
management.endpoints.enabled-by-default=false
management.endpoint.info.enabled=true
management.endpoint.health.enabled=true
nclazz.auth.token=