|
9 | 9 | import io.getstream.models.TrackActivityMetricsRequest; |
10 | 10 | import io.getstream.models.UpdateAppRequest; |
11 | 11 | import io.getstream.services.framework.StreamHTTPClient; |
| 12 | +import io.getstream.services.framework.StreamSDKClient; |
12 | 13 | import java.util.Date; |
13 | 14 | import java.util.List; |
14 | 15 | import java.util.Map; |
| 16 | +import java.util.concurrent.TimeUnit; |
| 17 | +import okhttp3.ConnectionPool; |
| 18 | +import okhttp3.OkHttpClient; |
15 | 19 | import org.junit.jupiter.api.BeforeAll; |
16 | 20 | import org.junit.jupiter.api.Test; |
17 | 21 |
|
@@ -135,6 +139,35 @@ void testTrackActivityMetricsRequestSerializedWithCustomMetric() throws JsonProc |
135 | 139 | assertTrue(json.contains("\"delta\":3"), "Expected delta in: " + json); |
136 | 140 | } |
137 | 141 |
|
| 142 | + @Test |
| 143 | + void testCustomOkHttpClientPreservesConfig() { |
| 144 | + ConnectionPool customPool = new ConnectionPool(20, 120, TimeUnit.SECONDS); |
| 145 | + OkHttpClient customHttp = |
| 146 | + new OkHttpClient.Builder() |
| 147 | + .connectionPool(customPool) |
| 148 | + .connectTimeout(30, TimeUnit.SECONDS) |
| 149 | + .readTimeout(45, TimeUnit.SECONDS) |
| 150 | + .build(); |
| 151 | + |
| 152 | + var sdkClient = |
| 153 | + new StreamSDKClient( |
| 154 | + System.getenv("STREAM_API_KEY"), System.getenv("STREAM_API_SECRET"), customHttp); |
| 155 | + OkHttpClient builtClient = sdkClient.getHttpClient().getHttpClient(); |
| 156 | + |
| 157 | + assertSame(customPool, builtClient.connectionPool()); |
| 158 | + assertEquals(30_000, builtClient.connectTimeoutMillis()); |
| 159 | + assertEquals(45_000, builtClient.readTimeoutMillis()); |
| 160 | + |
| 161 | + assertFalse( |
| 162 | + builtClient.interceptors().isEmpty(), "SDK should add its interceptors to the client"); |
| 163 | + } |
| 164 | + |
| 165 | + @Test |
| 166 | + void testDefaultConstructorStillWorks() { |
| 167 | + assertNotNull(client.getHttpClient()); |
| 168 | + assertFalse(client.getHttpClient().interceptors().isEmpty()); |
| 169 | + } |
| 170 | + |
138 | 171 | @Test |
139 | 172 | void testRFC3339TimestampParsing() throws Exception { |
140 | 173 | // Create a JSON response with RFC 3339 formatted timestamp |
|
0 commit comments