@@ -979,22 +979,25 @@ public void testHttpClientVertexWithRequestLevelRetryOptions() throws Exception
979979 @ Test
980980 public void testHttpClientMldevCustomClientOptions () throws Exception {
981981 ClientOptions clientOptions =
982- ClientOptions .builder ().maxConnections (64 ).maxConnectionsPerHost (16 ).build ();
982+ ClientOptions .builder ().maxConnections (64 ).maxConnectionsPerHost (16 ).readTimeout ( 5000 ). writeTimeout ( 4000 ). build ();
983983 HttpApiClient client =
984984 new HttpApiClient (Optional .of (API_KEY ), Optional .empty (), Optional .of (clientOptions ));
985985
986986 Dispatcher dispatcher = client .httpClient ().dispatcher ();
987+ OkHttpClient httpClient = client .httpClient ();
987988
988989 assertEquals (API_KEY , client .apiKey ());
989990 assertFalse (client .vertexAI ());
990991 assertEquals (64 , dispatcher .getMaxRequests ());
991992 assertEquals (16 , dispatcher .getMaxRequestsPerHost ());
993+ assertEquals (5000 , httpClient .readTimeoutMillis ());
994+ assertEquals (4000 , httpClient .writeTimeoutMillis ());
992995 }
993996
994997 @ Test
995998 public void testHttpClientVertexCustomClientOptions () throws Exception {
996999 ClientOptions clientOptions =
997- ClientOptions .builder ().maxConnections (64 ).maxConnectionsPerHost (16 ).build ();
1000+ ClientOptions .builder ().maxConnections (64 ).maxConnectionsPerHost (16 ).readTimeout ( 5000 ). writeTimeout ( 4000 ). build ();
9981001 HttpApiClient client =
9991002 new HttpApiClient (
10001003 Optional .empty (),
@@ -1005,12 +1008,15 @@ public void testHttpClientVertexCustomClientOptions() throws Exception {
10051008 Optional .of (clientOptions ));
10061009
10071010 Dispatcher dispatcher = client .httpClient ().dispatcher ();
1011+ OkHttpClient httpClient = client .httpClient ();
10081012
10091013 assertEquals (PROJECT , client .project ());
10101014 assertEquals (LOCATION , client .location ());
10111015 assertTrue (client .vertexAI ());
10121016 assertEquals (64 , dispatcher .getMaxRequests ());
10131017 assertEquals (16 , dispatcher .getMaxRequestsPerHost ());
1018+ assertEquals (5000 , httpClient .readTimeoutMillis ());
1019+ assertEquals (4000 , httpClient .writeTimeoutMillis ());
10141020 }
10151021
10161022 @ Test
@@ -1019,6 +1025,7 @@ public void testHttpClientMldevDefaultClientOptions() throws Exception {
10191025 new HttpApiClient (Optional .of (API_KEY ), Optional .empty (), Optional .empty ());
10201026
10211027 Dispatcher dispatcher = client .httpClient ().dispatcher ();
1028+ OkHttpClient httpClient = client .httpClient ();
10221029
10231030 // Default values for max connections and max connections per host are 64 and 5 respectively
10241031 // (set by OkHttp). When maxConnectionsPerHost is not set, the dispatcher's maxRequestsPerHost
@@ -1027,6 +1034,8 @@ public void testHttpClientMldevDefaultClientOptions() throws Exception {
10271034 assertEquals (5 , dispatcher .getMaxRequestsPerHost ());
10281035 assertEquals (API_KEY , client .apiKey ());
10291036 assertFalse (client .vertexAI ());
1037+ assertEquals (0 , httpClient .readTimeoutMillis ());
1038+ assertEquals (0 , httpClient .writeTimeoutMillis ());
10301039 }
10311040
10321041 @ Test
0 commit comments