|  | 
| 23 | 23 | import java.lang.annotation.Target; | 
| 24 | 24 | import java.net.URI; | 
| 25 | 25 | import java.nio.charset.StandardCharsets; | 
|  | 26 | +import java.time.Duration; | 
|  | 27 | +import java.time.ZoneId; | 
|  | 28 | +import java.time.ZonedDateTime; | 
|  | 29 | +import java.time.format.DateTimeFormatter; | 
| 26 | 30 | import java.util.ArrayList; | 
| 27 | 31 | import java.util.Arrays; | 
| 28 | 32 | import java.util.List; | 
|  | 
| 57 | 61 | import static org.junit.jupiter.api.Named.named; | 
| 58 | 62 | 
 | 
| 59 | 63 | /** | 
|  | 64 | + * Tests for {@link ClientHttpConnector} implementations. | 
| 60 | 65 |  * @author Arjen Poutsma | 
|  | 66 | + * @author Brian Clozel | 
| 61 | 67 |  */ | 
| 62 | 68 | class ClientHttpConnectorTests { | 
| 63 | 69 | 
 | 
| @@ -172,6 +178,26 @@ void cancelResponseBody(ClientHttpConnector connector) { | 
| 172 | 178 | 				.verify(); | 
| 173 | 179 | 	} | 
| 174 | 180 | 
 | 
|  | 181 | +	@ParameterizedConnectorTest | 
|  | 182 | +	void cookieExpireValueSetAsMaxAge(ClientHttpConnector connector) { | 
|  | 183 | +		ZonedDateTime tomorrow = ZonedDateTime.now(ZoneId.of("UTC")).plusDays(1); | 
|  | 184 | +		String formattedDate = tomorrow.format(DateTimeFormatter.RFC_1123_DATE_TIME); | 
|  | 185 | + | 
|  | 186 | +		prepareResponse(response -> { | 
|  | 187 | +			response.setResponseCode(200); | 
|  | 188 | +			response.addHeader("Set-Cookie", "id=test; Expires= " + formattedDate + ";"); | 
|  | 189 | +		}); | 
|  | 190 | +		Mono<ClientHttpResponse> futureResponse = | 
|  | 191 | +				connector.connect(HttpMethod.GET, this.server.url("/").uri(), ReactiveHttpOutputMessage::setComplete); | 
|  | 192 | +		StepVerifier.create(futureResponse) | 
|  | 193 | +				.assertNext(response -> { | 
|  | 194 | +							assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK); | 
|  | 195 | +							assertThat(response.getCookies().getFirst("id").getMaxAge()).isCloseTo(Duration.ofDays(1), Duration.ofSeconds(10)); | 
|  | 196 | +						} | 
|  | 197 | +				) | 
|  | 198 | +				.verifyComplete(); | 
|  | 199 | +	} | 
|  | 200 | + | 
| 175 | 201 | 	private Buffer randomBody(int size) { | 
| 176 | 202 | 		Buffer responseBody = new Buffer(); | 
| 177 | 203 | 		Random rnd = new Random(); | 
| @@ -211,7 +237,8 @@ static List<Named<ClientHttpConnector>> connectors() { | 
| 211 | 237 | 		return Arrays.asList( | 
| 212 | 238 | 				named("Reactor Netty", new ReactorClientHttpConnector()), | 
| 213 | 239 | 				named("Jetty", new JettyClientHttpConnector()), | 
| 214 |  | -				named("HttpComponents", new HttpComponentsClientHttpConnector()) | 
|  | 240 | +				named("HttpComponents", new HttpComponentsClientHttpConnector()), | 
|  | 241 | +				named("Jdk", new JdkClientHttpConnector()) | 
| 215 | 242 | 		); | 
| 216 | 243 | 	} | 
| 217 | 244 | 
 | 
|  | 
0 commit comments