Skip to content

Commit 8a7d2f8

Browse files
fix: Add tests
1 parent 2a32b20 commit 8a7d2f8

1 file changed

Lines changed: 31 additions & 0 deletions

File tree

src/test/java/com/scanoss/TestScanApi.java

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,37 @@ public void TestScanApiScanTimeoutNegative() {
200200
log.info("Finished {} -->", methodName);
201201
}
202202

203+
@Test
204+
public void TestScanApiReadTimeoutDisabled() {
205+
String methodName = new Object() {
206+
}.getClass().getEnclosingMethod().getName();
207+
log.info("<-- Starting {}", methodName);
208+
209+
// readTimeout = 0 (default) should produce an OkHttpClient with readTimeoutMillis == 0 (disabled)
210+
ScanApi scanApi = ScanApi.builder().url(server.url("/api/scan/direct").toString()).build();
211+
assertEquals("Read timeout should be 0 (disabled) by default",
212+
0, scanApi.getOkHttpClient().readTimeoutMillis());
213+
214+
log.info("Finished {} -->", methodName);
215+
}
216+
217+
@Test
218+
public void TestScanApiReadTimeoutConfigured() {
219+
String methodName = new Object() {
220+
}.getClass().getEnclosingMethod().getName();
221+
log.info("<-- Starting {}", methodName);
222+
223+
// readTimeout = 30s should be reflected in the underlying OkHttpClient
224+
ScanApi scanApi = ScanApi.builder()
225+
.url(server.url("/api/scan/direct").toString())
226+
.readTimeout(Duration.ofSeconds(30))
227+
.build();
228+
assertEquals("Read timeout should be 30 000 ms",
229+
30_000, scanApi.getOkHttpClient().readTimeoutMillis());
230+
231+
log.info("Finished {} -->", methodName);
232+
}
233+
203234
@Test
204235
public void TestScanApiTemplate() {
205236
String methodName = new Object() {

0 commit comments

Comments
 (0)