|
|
@ -29,6 +29,7 @@ import org.testcontainers.junit.jupiter.Testcontainers;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.boot.test.context.SpringBootTest;
|
|
|
|
import org.springframework.boot.test.context.SpringBootTest;
|
|
|
|
import org.springframework.boot.test.web.client.TestRestTemplate;
|
|
|
|
import org.springframework.boot.test.web.client.TestRestTemplate;
|
|
|
|
|
|
|
|
import org.springframework.boot.test.web.server.LocalServerPort;
|
|
|
|
import org.springframework.boot.testsupport.testcontainers.DockerImageNames;
|
|
|
|
import org.springframework.boot.testsupport.testcontainers.DockerImageNames;
|
|
|
|
import org.springframework.core.ParameterizedTypeReference;
|
|
|
|
import org.springframework.core.ParameterizedTypeReference;
|
|
|
|
import org.springframework.http.HttpHeaders;
|
|
|
|
import org.springframework.http.HttpHeaders;
|
|
|
@ -53,6 +54,9 @@ public class SampleSessionMongoApplicationTests {
|
|
|
|
@Autowired
|
|
|
|
@Autowired
|
|
|
|
private TestRestTemplate restTemplate;
|
|
|
|
private TestRestTemplate restTemplate;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@LocalServerPort
|
|
|
|
|
|
|
|
private int port;
|
|
|
|
|
|
|
|
|
|
|
|
@Container
|
|
|
|
@Container
|
|
|
|
static MongoDBContainer mongo = new MongoDBContainer(DockerImageNames.mongo()).withStartupAttempts(3)
|
|
|
|
static MongoDBContainer mongo = new MongoDBContainer(DockerImageNames.mongo()).withStartupAttempts(3)
|
|
|
|
.withStartupTimeout(Duration.ofMinutes(2));
|
|
|
|
.withStartupTimeout(Duration.ofMinutes(2));
|
|
|
@ -73,6 +77,15 @@ public class SampleSessionMongoApplicationTests {
|
|
|
|
assertThat(sessions.size()).isEqualTo(1);
|
|
|
|
assertThat(sessions.size()).isEqualTo(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
|
|
|
@SuppressWarnings("unchecked")
|
|
|
|
|
|
|
|
void health() {
|
|
|
|
|
|
|
|
ResponseEntity<String> entity = this.restTemplate
|
|
|
|
|
|
|
|
.getForEntity("http://localhost:" + this.port + "/actuator/health", String.class);
|
|
|
|
|
|
|
|
assertThat(entity.getBody()).contains("\"status\":\"UP\"");
|
|
|
|
|
|
|
|
assertThat(entity.getBody()).contains("maxWireVersion");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void createSession(URI uri) {
|
|
|
|
private void createSession(URI uri) {
|
|
|
|
RequestEntity<Object> request = getRequestEntity(uri);
|
|
|
|
RequestEntity<Object> request = getRequestEntity(uri);
|
|
|
|
this.restTemplate.exchange(request, String.class);
|
|
|
|
this.restTemplate.exchange(request, String.class);
|
|
|
|