BAEL-19868: Use random port in spring-session-mongodb IntegrationTest
This commit is contained in:
parent
2235656358
commit
b1c2b0bebc
|
@ -6,6 +6,7 @@ import org.junit.runner.RunWith;
|
|||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.boot.test.web.client.TestRestTemplate;
|
||||
import org.springframework.boot.web.server.LocalServerPort;
|
||||
import org.springframework.http.HttpEntity;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpMethod;
|
||||
|
@ -16,9 +17,12 @@ import java.util.Base64;
|
|||
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(classes = SpringSessionMongoDBApplication.class, webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT)
|
||||
@SpringBootTest(classes = SpringSessionMongoDBApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
|
||||
public class SpringSessionMongoDBIntegrationTest {
|
||||
|
||||
@LocalServerPort
|
||||
private int port;
|
||||
|
||||
@Autowired
|
||||
private MongoOperationsSessionRepository repository;
|
||||
|
||||
|
@ -27,7 +31,7 @@ public class SpringSessionMongoDBIntegrationTest {
|
|||
@Test
|
||||
public void givenEndpointIsCalledTwiceAndResponseIsReturned_whenMongoDBIsQueriedForCount_thenCountMustBeSame() {
|
||||
HttpEntity<String> response = restTemplate
|
||||
.exchange("http://localhost:" + 8080, HttpMethod.GET, null, String.class);
|
||||
.exchange("http://localhost:" + port, HttpMethod.GET, null, String.class);
|
||||
HttpHeaders headers = response.getHeaders();
|
||||
String set_cookie = headers.getFirst(HttpHeaders.SET_COOKIE);
|
||||
|
||||
|
|
Loading…
Reference in New Issue