|
21 | 21 | */ |
22 | 22 | package com.influxdb.spring.influx; |
23 | 23 |
|
| 24 | +import java.util.List; |
24 | 25 | import java.util.concurrent.TimeUnit; |
25 | 26 |
|
| 27 | +import javax.annotation.Nonnull; |
| 28 | + |
26 | 29 | import com.influxdb.client.InfluxDBClient; |
27 | 30 |
|
28 | 31 | import okhttp3.OkHttpClient; |
| 32 | +import okhttp3.Protocol; |
29 | 33 | import org.assertj.core.api.Assertions; |
30 | 34 | import org.junit.jupiter.api.Test; |
31 | 35 | import org.junit.platform.runner.JUnitPlatform; |
@@ -96,11 +100,27 @@ public void influxDBClientWithReadTimeout() { |
96 | 100 | }); |
97 | 101 | } |
98 | 102 |
|
| 103 | + @Test |
| 104 | + public void protocolVersion() { |
| 105 | + this.contextRunner.withPropertyValues("spring.influx2.url=http://localhost:8086/", "spring.influx2.token:token") |
| 106 | + .run((context) -> { |
| 107 | + List<Protocol> protocols = getOkHttpClient(context).protocols(); |
| 108 | + Assertions.assertThat(protocols).hasSize(1); |
| 109 | + Assertions.assertThat(protocols).contains(Protocol.HTTP_1_1); |
| 110 | + }); |
| 111 | + } |
| 112 | + |
99 | 113 | private int getReadTimeoutProperty(AssertableApplicationContext context) { |
| 114 | + OkHttpClient callFactory = getOkHttpClient(context); |
| 115 | + return callFactory.readTimeoutMillis(); |
| 116 | + } |
| 117 | + |
| 118 | + @Nonnull |
| 119 | + private OkHttpClient getOkHttpClient(final AssertableApplicationContext context) { |
100 | 120 | InfluxDBClient influxDB = context.getBean(InfluxDBClient.class); |
101 | 121 | Retrofit retrofit = (Retrofit) ReflectionTestUtils.getField(influxDB, "retrofit"); |
102 | 122 | OkHttpClient callFactory = (OkHttpClient) retrofit.callFactory(); |
103 | | - return callFactory.readTimeoutMillis(); |
| 123 | + return callFactory; |
104 | 124 | } |
105 | 125 |
|
106 | 126 | @Configuration |
|
0 commit comments