Skip to content
Snippets Groups Projects
Unverified Commit 9ac9ac04 authored by Martin Weise's avatar Martin Weise
Browse files

Added actuator tests and swagger endpoint tests

parent 3dd8f458
Branches
Tags
2 merge requests!163Relase 1.3.0,!162Resolve "Improve Semantic Service handling"
This commit is part of merge request !162. Comments created here will be created in the context of that merge request.
Showing
with 616 additions and 15 deletions
......@@ -30,6 +30,8 @@ ENV METADATA_USERNAME=root
ENV METADATA_PASSWORD=dbrepo
ENV BROKER_USERNAME=fda
ENV BROKER_PASSWORD=fda
ENV ELASTIC_USERNAME=elastic
ENV ELASTIC_PASSWORD=elastic
ENV SHARED_FILESYSTEM=/tmp
ENV USER_NETWORK=userdb
ENV LOG_LEVEL=debug
......
......@@ -88,10 +88,6 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-elasticsearch</artifactId>
</dependency>
<!-- Entity and API -->
<dependency>
<groupId>at.tuwien</groupId>
......
......@@ -3,7 +3,6 @@ package at.tuwien;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.data.elasticsearch.repository.config.EnableElasticsearchRepositories;
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.transaction.annotation.EnableTransactionManagement;
......@@ -11,7 +10,6 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
@SpringBootApplication
@EnableJpaAuditing
@EnableTransactionManagement
@EnableElasticsearchRepositories(basePackages = {"at.tuwien.repository.elastic"})
@EnableJpaRepositories(basePackages = {"at.tuwien.repository.jpa"})
@EntityScan(basePackages = {"at.tuwien.entities"})
public class DbrepoContainerManagingApplication {
......
......@@ -27,6 +27,10 @@ spring:
virtual-host: dbrepo
username: fda
password: fda
elasticsearch:
password: elastic
username: elastic
uris: http://localhost:9200
management.endpoints.web.exposure.include: health,info,prometheus
springdoc.swagger-ui.enabled: true
server:
......
......@@ -27,6 +27,10 @@ spring:
virtual-host: dbrepo
username: "${BROKER_USERNAME}"
password: "${BROKER_PASSWORD}"
elasticsearch:
password: "${ELASTIC_PASSWORD}"
username: "${ELASTIC_USERNAME}"
uris: http://search-service:9200
management.endpoints.web.exposure.include: health,info,prometheus
springdoc.swagger-ui.enabled: true
server:
......
package at.tuwien.endpoint;
import at.tuwien.BaseUnitTest;
import lombok.extern.log4j.Log4j2;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
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.junit.jupiter.SpringExtension;
import org.springframework.test.web.servlet.MockMvc;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
@Log4j2
@ExtendWith(SpringExtension.class)
@AutoConfigureMockMvc
@SpringBootTest
public class ActuatorComponentTest extends BaseUnitTest {
@Autowired
private MockMvc mockMvc;
@Test
public void actuatorInfo_succeeds() throws Exception {
this.mockMvc.perform(get("/actuator/info"))
.andDo(print())
.andExpect(status().isOk());
}
@Test
public void actuatorStatus_succeeds() throws Exception {
this.mockMvc.perform(get("/actuator/health"));
}
@Test
public void actuatorPrometheus_succeeds() throws Exception {
this.mockMvc.perform(get("/actuator/prometheus"));
}
}
package at.tuwien.endpoint;
import at.tuwien.BaseUnitTest;
import lombok.extern.log4j.Log4j2;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
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.junit.jupiter.SpringExtension;
import org.springframework.test.web.servlet.MockMvc;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
@Log4j2
@ExtendWith(SpringExtension.class)
@AutoConfigureMockMvc
@SpringBootTest
public class SwaggerComponentTest extends BaseUnitTest {
@Autowired
private MockMvc mockMvc;
@Test
public void swaggerUi_succeeds() throws Exception {
this.mockMvc.perform(get("/swagger-ui/index.html"))
.andDo(print())
.andExpect(status().isOk());
}
}
package at.tuwien.repository.elastic;
import at.tuwien.entities.database.Database;
import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;
import org.springframework.stereotype.Repository;
@Repository(value = "ElasticDatabaseService")
public interface DatabaseRepository extends ElasticsearchRepository<Database, Long> {
}
\ No newline at end of file
package at.tuwien.endpoint;
import at.tuwien.BaseUnitTest;
import at.tuwien.config.IndexConfig;
import com.rabbitmq.client.Channel;
import lombok.extern.log4j.Log4j2;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
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.boot.test.mock.mockito.MockBean;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.test.web.servlet.MockMvc;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
@Log4j2
@ExtendWith(SpringExtension.class)
@AutoConfigureMockMvc
@SpringBootTest
public class ActuatorComponentTest extends BaseUnitTest {
@Autowired
private MockMvc mockMvc;
@MockBean
private Channel channel;
@MockBean
private IndexConfig indexConfig;
@Test
public void actuatorInfo_succeeds() throws Exception {
this.mockMvc.perform(get("/actuator/info"))
.andDo(print())
.andExpect(status().isOk());
}
@Test
public void actuatorStatus_succeeds() throws Exception {
this.mockMvc.perform(get("/actuator/health"));
}
@Test
public void actuatorPrometheus_succeeds() throws Exception {
this.mockMvc.perform(get("/actuator/prometheus"));
}
}
package at.tuwien.endpoint;
import at.tuwien.BaseUnitTest;
import at.tuwien.config.IndexConfig;
import com.rabbitmq.client.Channel;
import lombok.extern.log4j.Log4j2;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
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.boot.test.mock.mockito.MockBean;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.test.web.servlet.MockMvc;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
@Log4j2
@ExtendWith(SpringExtension.class)
@AutoConfigureMockMvc
@SpringBootTest
public class SwaggerComponentTest extends BaseUnitTest {
@Autowired
private MockMvc mockMvc;
@MockBean
private Channel channel;
@MockBean
private IndexConfig indexConfig;
@Test
public void swaggerUi_succeeds() throws Exception {
this.mockMvc.perform(get("/swagger-ui/index.html"))
.andDo(print())
.andExpect(status().isOk());
}
}
package at.tuwien.endpoint;
import at.tuwien.BaseUnitTest;
import at.tuwien.config.IndexInitializer;
import lombok.extern.log4j.Log4j2;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
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.boot.test.mock.mockito.MockBean;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.test.web.servlet.MockMvc;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
@Log4j2
@ExtendWith(SpringExtension.class)
@AutoConfigureMockMvc
@SpringBootTest
public class ActuatorComponentTest extends BaseUnitTest {
@Autowired
private MockMvc mockMvc;
@MockBean
private IndexInitializer indexConfig;
@Test
public void actuatorInfo_succeeds() throws Exception {
this.mockMvc.perform(get("/actuator/info"))
.andDo(print())
.andExpect(status().isOk());
}
@Test
public void actuatorStatus_succeeds() throws Exception {
this.mockMvc.perform(get("/actuator/health"));
}
@Test
public void actuatorPrometheus_succeeds() throws Exception {
this.mockMvc.perform(get("/actuator/prometheus"));
}
}
package at.tuwien.endpoint;
import at.tuwien.BaseUnitTest;
import at.tuwien.config.IndexInitializer;
import lombok.extern.log4j.Log4j2;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
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.boot.test.mock.mockito.MockBean;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.test.web.servlet.MockMvc;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
@Log4j2
@ExtendWith(SpringExtension.class)
@AutoConfigureMockMvc
@SpringBootTest
public class SwaggerComponentTest extends BaseUnitTest {
@Autowired
private MockMvc mockMvc;
@MockBean
private IndexInitializer indexConfig;
@Test
public void swaggerUi_succeeds() throws Exception {
this.mockMvc.perform(get("/swagger-ui/index.html"))
.andDo(print())
.andExpect(status().isOk());
}
}
package at.tuwien.endpoint;
import at.tuwien.BaseUnitTest;
import at.tuwien.config.IndexConfig;
import com.rabbitmq.client.Channel;
import lombok.extern.log4j.Log4j2;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
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.boot.test.mock.mockito.MockBean;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.test.web.servlet.MockMvc;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
@Log4j2
@ExtendWith(SpringExtension.class)
@AutoConfigureMockMvc
@SpringBootTest
public class ActuatorComponentTest extends BaseUnitTest {
@Autowired
private MockMvc mockMvc;
@MockBean
private Channel channel;
@MockBean
private IndexConfig indexConfig;
@Test
public void actuatorInfo_succeeds() throws Exception {
this.mockMvc.perform(get("/actuator/info"))
.andDo(print())
.andExpect(status().isOk());
}
@Test
public void actuatorStatus_succeeds() throws Exception {
this.mockMvc.perform(get("/actuator/health"));
}
@Test
public void actuatorPrometheus_succeeds() throws Exception {
this.mockMvc.perform(get("/actuator/prometheus"));
}
}
package at.tuwien.endpoint;
import at.tuwien.BaseUnitTest;
import at.tuwien.config.IndexConfig;
import com.rabbitmq.client.Channel;
import lombok.extern.log4j.Log4j2;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
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.boot.test.mock.mockito.MockBean;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.test.web.servlet.MockMvc;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
@Log4j2
@ExtendWith(SpringExtension.class)
@AutoConfigureMockMvc
@SpringBootTest
public class SwaggerComponentTest extends BaseUnitTest {
@Autowired
private MockMvc mockMvc;
@MockBean
private Channel channel;
@MockBean
private IndexConfig indexConfig;
@Test
public void swaggerUi_succeeds() throws Exception {
this.mockMvc.perform(get("/swagger-ui/index.html"))
.andDo(print())
.andExpect(status().isOk());
}
}
package at.tuwien.endpoint;
import at.tuwien.BaseUnitTest;
import lombok.extern.log4j.Log4j2;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
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.junit.jupiter.SpringExtension;
import org.springframework.test.web.servlet.MockMvc;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
@Log4j2
@ExtendWith(SpringExtension.class)
@AutoConfigureMockMvc
@SpringBootTest
public class ActuatorComponentTest extends BaseUnitTest {
@Autowired
private MockMvc mockMvc;
@Test
public void actuatorInfo_succeeds() throws Exception {
this.mockMvc.perform(get("/actuator/info"))
.andDo(print())
.andExpect(status().isOk());
}
@Test
public void actuatorStatus_succeeds() throws Exception {
this.mockMvc.perform(get("/actuator/health"));
}
@Test
public void actuatorPrometheus_succeeds() throws Exception {
this.mockMvc.perform(get("/actuator/prometheus"));
}
}
package at.tuwien.endpoint;
import at.tuwien.BaseUnitTest;
import lombok.extern.log4j.Log4j2;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
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.junit.jupiter.SpringExtension;
import org.springframework.test.web.servlet.MockMvc;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
@Log4j2
@ExtendWith(SpringExtension.class)
@AutoConfigureMockMvc
@SpringBootTest
public class SwaggerComponentTest extends BaseUnitTest {
@Autowired
private MockMvc mockMvc;
@Test
public void swaggerUi_succeeds() throws Exception {
this.mockMvc.perform(get("/swagger-ui/index.html"))
.andDo(print())
.andExpect(status().isOk());
}
}
package at.tuwien.endpoint;
import at.tuwien.BaseUnitTest;
import at.tuwien.config.IndexConfig;
import com.rabbitmq.client.Channel;
import lombok.extern.log4j.Log4j2;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
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.boot.test.mock.mockito.MockBean;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.test.web.servlet.MockMvc;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
@Log4j2
@ExtendWith(SpringExtension.class)
@AutoConfigureMockMvc
@SpringBootTest
public class ActuatorComponentTest extends BaseUnitTest {
@Autowired
private MockMvc mockMvc;
@MockBean
private Channel channel;
@MockBean
private IndexConfig indexConfig;
@Test
public void actuatorInfo_succeeds() throws Exception {
this.mockMvc.perform(get("/actuator/info"))
.andDo(print())
.andExpect(status().isOk());
}
@Test
public void actuatorStatus_succeeds() throws Exception {
this.mockMvc.perform(get("/actuator/health"));
}
@Test
public void actuatorPrometheus_succeeds() throws Exception {
this.mockMvc.perform(get("/actuator/prometheus"));
}
}
package at.tuwien.endpoint;
import at.tuwien.BaseUnitTest;
import at.tuwien.config.IndexConfig;
import com.rabbitmq.client.Channel;
import lombok.extern.log4j.Log4j2;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
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.boot.test.mock.mockito.MockBean;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.test.web.servlet.MockMvc;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
@Log4j2
@ExtendWith(SpringExtension.class)
@AutoConfigureMockMvc
@SpringBootTest
public class SwaggerComponentTest extends BaseUnitTest {
@Autowired
private MockMvc mockMvc;
@MockBean
private Channel channel;
@MockBean
private IndexConfig indexConfig;
@Test
public void swaggerUi_succeeds() throws Exception {
this.mockMvc.perform(get("/swagger-ui/index.html"))
.andDo(print())
.andExpect(status().isOk());
}
}
package at.tuwien.endpoint;
import at.tuwien.BaseUnitTest;
import com.rabbitmq.client.Channel;
import lombok.extern.log4j.Log4j2;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
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.boot.test.mock.mockito.MockBean;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.test.web.servlet.MockMvc;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
@Log4j2
@ExtendWith(SpringExtension.class)
@AutoConfigureMockMvc
@SpringBootTest
public class ActuatorComponentTest extends BaseUnitTest {
@Autowired
private MockMvc mockMvc;
@MockBean
private Channel channel;
@Test
public void actuatorInfo_succeeds() throws Exception {
this.mockMvc.perform(get("/actuator/info"))
.andDo(print())
.andExpect(status().isOk());
}
@Test
public void actuatorStatus_succeeds() throws Exception {
this.mockMvc.perform(get("/actuator/health"));
}
@Test
public void actuatorPrometheus_succeeds() throws Exception {
this.mockMvc.perform(get("/actuator/prometheus"));
}
}
package at.tuwien.endpoint;
import at.tuwien.BaseUnitTest;
import com.rabbitmq.client.Channel;
import lombok.extern.log4j.Log4j2;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
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.boot.test.mock.mockito.MockBean;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.test.web.servlet.MockMvc;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
@Log4j2
@ExtendWith(SpringExtension.class)
@AutoConfigureMockMvc
@SpringBootTest
public class SwaggerComponentTest extends BaseUnitTest {
@Autowired
private MockMvc mockMvc;
@MockBean
private Channel channel;
@Test
public void swaggerUi_succeeds() throws Exception {
this.mockMvc.perform(get("/swagger-ui/index.html"))
.andDo(print())
.andExpect(status().isOk());
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment