|
1 | 1 | package com.baeldung.cachecontrol; |
2 | 2 |
|
3 | | -import io.restassured.http.ContentType; |
4 | | -import org.junit.Test; |
5 | | -import org.junit.runner.RunWith; |
| 3 | +import static io.restassured.RestAssured.given; |
| 4 | + |
| 5 | +import org.junit.jupiter.api.Test; |
6 | 6 | import org.springframework.boot.test.context.SpringBootTest; |
7 | 7 | import org.springframework.boot.test.web.server.LocalServerPort; |
8 | | -import org.springframework.test.context.junit4.SpringRunner; |
9 | 8 |
|
10 | | -import static io.restassured.RestAssured.given; |
| 9 | +import io.restassured.http.ContentType; |
11 | 10 |
|
12 | | -@RunWith(SpringRunner.class) |
13 | 11 | @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = AppRunner.class) |
14 | | -public class ResourceEndpointIntegrationTest { |
| 12 | +class ResourceEndpointIntegrationTest { |
15 | 13 |
|
16 | 14 | @LocalServerPort |
17 | 15 | private int serverPort; |
18 | 16 |
|
19 | 17 | @Test |
20 | | - public void whenGetRequestForUser_shouldRespondWithDefaultCacheHeaders() { |
| 18 | + void whenGetRequestForUser_shouldRespondWithDefaultCacheHeaders() { |
21 | 19 | given().when().get(getBaseUrl() + "/default/users/Michael").then().headers("Cache-Control", "no-cache, no-store, max-age=0, must-revalidate").header("Pragma", "no-cache"); |
22 | 20 | } |
23 | 21 |
|
24 | 22 | @Test |
25 | | - public void whenGetRequestForUser_shouldRespondMaxAgeCacheControl() { |
| 23 | + void whenGetRequestForUser_shouldRespondMaxAgeCacheControl() { |
26 | 24 | given().when().get(getBaseUrl() + "/users/Michael").then().header("Cache-Control", "max-age=60"); |
27 | 25 | } |
28 | 26 |
|
29 | 27 | @Test |
30 | | - public void givenServiceEndpoint_whenGetRequestForUser_shouldResponseWithCacheControlMaxAge() { |
| 28 | + void givenServiceEndpoint_whenGetRequestForUser_shouldResponseWithCacheControlMaxAge() { |
31 | 29 | given().when().get(getBaseUrl() + "/users/Michael").then().contentType(ContentType.JSON).and().statusCode(200).and().header("Cache-Control", "max-age=60"); |
32 | 30 | } |
33 | 31 |
|
34 | 32 | @Test |
35 | | - public void givenServiceEndpoint_whenGetRequestForNotCacheableContent_shouldResponseWithCacheControlNoCache() { |
| 33 | + void givenServiceEndpoint_whenGetRequestForNotCacheableContent_shouldResponseWithCacheControlNoCache() { |
36 | 34 | given().when().get(getBaseUrl() + "/timestamp").then().contentType(ContentType.JSON).and().statusCode(200).and().header("Cache-Control", "no-store"); |
37 | 35 | } |
38 | 36 |
|
39 | 37 | @Test |
40 | | - public void givenServiceEndpoint_whenGetRequestForPrivateUser_shouldResponseWithSecurityDefaultCacheControl() { |
| 38 | + void givenServiceEndpoint_whenGetRequestForPrivateUser_shouldResponseWithSecurityDefaultCacheControl() { |
41 | 39 | given().when().get(getBaseUrl() + "/private/users/Michael").then().contentType(ContentType.JSON).and().statusCode(200).and().header("Cache-Control", "no-cache, no-store, max-age=0, must-revalidate"); |
42 | 40 | } |
43 | 41 |
|
|
0 commit comments