|
3 | 3 | import org.example.github.BasicClientInterface;
|
4 | 4 | import org.junit.jupiter.api.Test;
|
5 | 5 |
|
6 |
| -import java.net.http.HttpClient; |
7 | 6 | import java.nio.charset.StandardCharsets;
|
8 | 7 |
|
9 | 8 | import static org.assertj.core.api.Assertions.assertThat;
|
@@ -40,49 +39,49 @@ void gzip_contentDecode() {
|
40 | 39 | @Test
|
41 | 40 | void build_basic() {
|
42 | 41 |
|
43 |
| - final HttpClientContext context = |
44 |
| - HttpClientContext.builder() |
| 42 | + final HttpClient client = |
| 43 | + HttpClient.builder() |
45 | 44 | .baseUrl("http://localhost")
|
46 | 45 | .build();
|
47 | 46 |
|
48 |
| - SpiHttpClient spi = (SpiHttpClient)context; |
| 47 | + SpiHttpClient spi = (SpiHttpClient)client; |
49 | 48 | // has default client created
|
50 | 49 | assertThat(spi.httpClient()).isNotNull();
|
51 |
| - assertThat(spi.httpClient().version()).isEqualTo(HttpClient.Version.HTTP_2); |
| 50 | + assertThat(spi.httpClient().version()).isEqualTo(java.net.http.HttpClient.Version.HTTP_2); |
52 | 51 | assertThat(spi.httpClient().cookieHandler()).isPresent();
|
53 | 52 |
|
54 | 53 | // has expected url building
|
55 |
| - assertThat(spi.url().build()).isEqualTo("http://localhost"); |
56 |
| - assertThat(spi.url().path("hello").build()).isEqualTo("http://localhost/hello"); |
57 |
| - assertThat(spi.url().queryParam("hello","there").build()).isEqualTo("http://localhost?hello=there"); |
| 54 | + assertThat(client.url().build()).isEqualTo("http://localhost"); |
| 55 | + assertThat(client.url().path("hello").build()).isEqualTo("http://localhost/hello"); |
| 56 | + assertThat(client.url().queryParam("hello","there").build()).isEqualTo("http://localhost?hello=there"); |
58 | 57 | }
|
59 | 58 |
|
60 | 59 | @Test
|
61 | 60 | void build_noCookieHandler() {
|
62 | 61 |
|
63 |
| - final HttpClientContext context = |
64 |
| - HttpClientContext.builder() |
| 62 | + final HttpClient client = |
| 63 | + HttpClient.builder() |
65 | 64 | .baseUrl("http://localhost")
|
66 | 65 | .cookieHandler(null)
|
67 |
| - .redirect(HttpClient.Redirect.ALWAYS) |
| 66 | + .redirect(java.net.http.HttpClient.Redirect.ALWAYS) |
68 | 67 | .build();
|
69 | 68 |
|
70 |
| - SpiHttpClient spi = (SpiHttpClient)context; |
| 69 | + SpiHttpClient spi = (SpiHttpClient)client; |
71 | 70 | // has default client created
|
72 | 71 | assertThat(spi.httpClient()).isNotNull();
|
73 |
| - assertThat(spi.httpClient().version()).isEqualTo(HttpClient.Version.HTTP_2); |
| 72 | + assertThat(spi.httpClient().version()).isEqualTo(java.net.http.HttpClient.Version.HTTP_2); |
74 | 73 | assertThat(spi.httpClient().cookieHandler()).isEmpty();
|
75 | 74 |
|
76 | 75 | // has expected url building
|
77 |
| - assertThat(spi.url().build()).isEqualTo("http://localhost"); |
78 |
| - assertThat(spi.url().path("hello").build()).isEqualTo("http://localhost/hello"); |
79 |
| - assertThat(spi.url().queryParam("hello","there").build()).isEqualTo("http://localhost?hello=there"); |
| 76 | + assertThat(client.url().build()).isEqualTo("http://localhost"); |
| 77 | + assertThat(client.url().path("hello").build()).isEqualTo("http://localhost/hello"); |
| 78 | + assertThat(client.url().queryParam("hello","there").build()).isEqualTo("http://localhost?hello=there"); |
80 | 79 | }
|
81 | 80 |
|
82 | 81 | @Test
|
83 | 82 | void build_missingBaseUrl() {
|
84 | 83 | try {
|
85 |
| - HttpClientContext.builder().build(); |
| 84 | + HttpClient.builder().build(); |
86 | 85 | } catch (NullPointerException e) {
|
87 | 86 | assertThat(e.getMessage()).contains("baseUrl is not specified");
|
88 | 87 | }
|
|
0 commit comments