adding "Read Timeout" getters and setters for the Jersey and OkHttp (#6853)

* adding "Read Timeout" getters and setters for the Jersey and OkHttp
based ApiClients

adding "Write Timeout" getters and setters for the OkHttp based
ApiClient

adding tests for the OkHttpClient covering the new getters and setters

* generated files from the bin scripts
This commit is contained in:
Andrew Norman 2017-11-09 20:12:40 -08:00 committed by wing328
parent 9a44512d03
commit 372a08763d
6 changed files with 188 additions and 10 deletions

View File

@ -306,6 +306,27 @@ public class ApiClient {
return this;
}
/**
* read timeout (in milliseconds).
* @return Read timeout
*/
public int getReadTimeout() {
return readTimeout;
}
/**
* Set the read timeout (in milliseconds).
* A value of 0 means no timeout, otherwise values must be between 1 and
* {@link Integer#MAX_VALUE}.
* @param readTimeout Read timeout in milliseconds
* @return API client
*/
public ApiClient setReadTimeout(int readTimeout) {
this.readTimeout = readTimeout;
httpClient.property(ClientProperties.READ_TIMEOUT, readTimeout);
return this;
}
/**
* Get the date format used to parse/format date parameters.
* @return Date format

View File

@ -426,7 +426,7 @@ public class ApiClient {
}
/**
* Set the tempoaray folder path (for downloading files)
* Set the temporary folder path (for downloading files)
*
* @param tempFolderPath Temporary folder path
* @return ApiClient
@ -448,6 +448,7 @@ public class ApiClient {
/**
* Sets the connect timeout (in milliseconds).
* A value of 0 means no timeout, otherwise values must be between 1 and
* {@link Integer#MAX_VALUE}.
*
* @param connectionTimeout connection timeout in milliseconds
* @return Api client
@ -457,6 +458,50 @@ public class ApiClient {
return this;
}
/**
* Get read timeout (in milliseconds).
*
* @return Timeout in milliseconds
*/
public int getReadTimeout() {
return httpClient.getReadTimeout();
}
/**
* Sets the read timeout (in milliseconds).
* A value of 0 means no timeout, otherwise values must be between 1 and
* {@link Integer#MAX_VALUE}.
*
* @param readTimeout read timeout in milliseconds
* @return Api client
*/
public ApiClient setReadTimeout(int readTimeout) {
httpClient.setReadTimeout(readTimeout, TimeUnit.MILLISECONDS);
return this;
}
/**
* Get write timeout (in milliseconds).
*
* @return Timeout in milliseconds
*/
public int getWriteTimeout() {
return httpClient.getWriteTimeout();
}
/**
* Sets the write timeout (in milliseconds).
* A value of 0 means no timeout, otherwise values must be between 1 and
* {@link Integer#MAX_VALUE}.
*
* @param writeTimeout connection timeout in milliseconds
* @return Api client
*/
public ApiClient setWriteTimeout(int writeTimeout) {
httpClient.setWriteTimeout(writeTimeout, TimeUnit.MILLISECONDS);
return this;
}
/**
* Format the given parameter object into string.
*

View File

@ -406,7 +406,7 @@ public class ApiClient {
}
/**
* Set the tempoaray folder path (for downloading files)
* Set the temporary folder path (for downloading files)
*
* @param tempFolderPath Temporary folder path
* @return ApiClient
@ -428,6 +428,7 @@ public class ApiClient {
/**
* Sets the connect timeout (in milliseconds).
* A value of 0 means no timeout, otherwise values must be between 1 and
* {@link Integer#MAX_VALUE}.
*
* @param connectionTimeout connection timeout in milliseconds
* @return Api client
@ -437,6 +438,50 @@ public class ApiClient {
return this;
}
/**
* Get read timeout (in milliseconds).
*
* @return Timeout in milliseconds
*/
public int getReadTimeout() {
return httpClient.getReadTimeout();
}
/**
* Sets the read timeout (in milliseconds).
* A value of 0 means no timeout, otherwise values must be between 1 and
* {@link Integer#MAX_VALUE}.
*
* @param readTimeout read timeout in milliseconds
* @return Api client
*/
public ApiClient setReadTimeout(int readTimeout) {
httpClient.setReadTimeout(readTimeout, TimeUnit.MILLISECONDS);
return this;
}
/**
* Get write timeout (in milliseconds).
*
* @return Timeout in milliseconds
*/
public int getWriteTimeout() {
return httpClient.getWriteTimeout();
}
/**
* Sets the write timeout (in milliseconds).
* A value of 0 means no timeout, otherwise values must be between 1 and
* {@link Integer#MAX_VALUE}.
*
* @param writeTimeout connection timeout in milliseconds
* @return Api client
*/
public ApiClient setWriteTimeout(int writeTimeout) {
httpClient.setWriteTimeout(writeTimeout, TimeUnit.MILLISECONDS);
return this;
}
/**
* Format the given parameter object into string.
*

View File

@ -63,7 +63,7 @@ public class FakeApi {
*/
public com.squareup.okhttp.Call testCodeInjectEndRnNRCall(String testCodeInjectEndRnNR, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
Object localVarPostBody = null;
// create path and map variables
String localVarPath = "/fake";
@ -103,18 +103,14 @@ public class FakeApi {
String[] localVarAuthNames = new String[] { };
return apiClient.buildCall(localVarPath, "PUT", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
}
@SuppressWarnings("rawtypes")
private com.squareup.okhttp.Call testCodeInjectEndRnNRValidateBeforeCall(String testCodeInjectEndRnNR, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
com.squareup.okhttp.Call call = testCodeInjectEndRnNRCall(testCodeInjectEndRnNR, progressListener, progressRequestListener);
return call;
}
/**

View File

@ -408,7 +408,7 @@ public class ApiClient {
}
/**
* Set the tempoaray folder path (for downloading files)
* Set the temporary folder path (for downloading files)
*
* @param tempFolderPath Temporary folder path
* @return ApiClient
@ -430,6 +430,7 @@ public class ApiClient {
/**
* Sets the connect timeout (in milliseconds).
* A value of 0 means no timeout, otherwise values must be between 1 and
* {@link Integer#MAX_VALUE}.
*
* @param connectionTimeout connection timeout in milliseconds
* @return Api client
@ -439,6 +440,50 @@ public class ApiClient {
return this;
}
/**
* Get read timeout (in milliseconds).
*
* @return Timeout in milliseconds
*/
public int getReadTimeout() {
return httpClient.getReadTimeout();
}
/**
* Sets the read timeout (in milliseconds).
* A value of 0 means no timeout, otherwise values must be between 1 and
* {@link Integer#MAX_VALUE}.
*
* @param readTimeout read timeout in milliseconds
* @return Api client
*/
public ApiClient setReadTimeout(int readTimeout) {
httpClient.setReadTimeout(readTimeout, TimeUnit.MILLISECONDS);
return this;
}
/**
* Get write timeout (in milliseconds).
*
* @return Timeout in milliseconds
*/
public int getWriteTimeout() {
return httpClient.getWriteTimeout();
}
/**
* Sets the write timeout (in milliseconds).
* A value of 0 means no timeout, otherwise values must be between 1 and
* {@link Integer#MAX_VALUE}.
*
* @param writeTimeout connection timeout in milliseconds
* @return Api client
*/
public ApiClient setWriteTimeout(int writeTimeout) {
httpClient.setWriteTimeout(writeTimeout, TimeUnit.MILLISECONDS);
return this;
}
/**
* Format the given parameter object into string.
*

View File

@ -165,7 +165,33 @@ public class ApiClientTest {
apiClient.setConnectTimeout(10000);
}
@Test
public void testGetAndSetReadTimeout() {
// read timeout defaults to 10 seconds
assertEquals(10000, apiClient.getReadTimeout());
assertEquals(10000, apiClient.getHttpClient().getReadTimeout());
apiClient.setReadTimeout(0);
assertEquals(0, apiClient.getReadTimeout());
assertEquals(0, apiClient.getHttpClient().getReadTimeout());
apiClient.setReadTimeout(10000);
}
@Test
public void testGetAndSetWriteTimeout() {
// write timeout defaults to 10 seconds
assertEquals(10000, apiClient.getWriteTimeout());
assertEquals(10000, apiClient.getHttpClient().getWriteTimeout());
apiClient.setWriteTimeout(0);
assertEquals(0, apiClient.getWriteTimeout());
assertEquals(0, apiClient.getHttpClient().getWriteTimeout());
apiClient.setWriteTimeout(10000);
}
@Test
public void testParameterToPairWhenNameIsInvalid() throws Exception {
List<Pair> pairs_a = apiClient.parameterToPair(null, new Integer(1));