mirror of
https://github.com/valitydev/openapi-generator.git
synced 2024-11-07 02:55:19 +00:00
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:
parent
9a44512d03
commit
372a08763d
@ -306,6 +306,27 @@ public class ApiClient {
|
|||||||
return this;
|
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.
|
* Get the date format used to parse/format date parameters.
|
||||||
* @return Date format
|
* @return Date format
|
||||||
|
@ -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
|
* @param tempFolderPath Temporary folder path
|
||||||
* @return ApiClient
|
* @return ApiClient
|
||||||
@ -448,6 +448,7 @@ public class ApiClient {
|
|||||||
/**
|
/**
|
||||||
* Sets the connect timeout (in milliseconds).
|
* Sets the connect timeout (in milliseconds).
|
||||||
* A value of 0 means no timeout, otherwise values must be between 1 and
|
* A value of 0 means no timeout, otherwise values must be between 1 and
|
||||||
|
* {@link Integer#MAX_VALUE}.
|
||||||
*
|
*
|
||||||
* @param connectionTimeout connection timeout in milliseconds
|
* @param connectionTimeout connection timeout in milliseconds
|
||||||
* @return Api client
|
* @return Api client
|
||||||
@ -457,6 +458,50 @@ public class ApiClient {
|
|||||||
return this;
|
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.
|
* Format the given parameter object into string.
|
||||||
*
|
*
|
||||||
|
@ -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
|
* @param tempFolderPath Temporary folder path
|
||||||
* @return ApiClient
|
* @return ApiClient
|
||||||
@ -428,6 +428,7 @@ public class ApiClient {
|
|||||||
/**
|
/**
|
||||||
* Sets the connect timeout (in milliseconds).
|
* Sets the connect timeout (in milliseconds).
|
||||||
* A value of 0 means no timeout, otherwise values must be between 1 and
|
* A value of 0 means no timeout, otherwise values must be between 1 and
|
||||||
|
* {@link Integer#MAX_VALUE}.
|
||||||
*
|
*
|
||||||
* @param connectionTimeout connection timeout in milliseconds
|
* @param connectionTimeout connection timeout in milliseconds
|
||||||
* @return Api client
|
* @return Api client
|
||||||
@ -437,6 +438,50 @@ public class ApiClient {
|
|||||||
return this;
|
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.
|
* Format the given parameter object into string.
|
||||||
*
|
*
|
||||||
|
@ -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 {
|
public com.squareup.okhttp.Call testCodeInjectEndRnNRCall(String testCodeInjectEndRnNR, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
|
||||||
Object localVarPostBody = null;
|
Object localVarPostBody = null;
|
||||||
|
|
||||||
// create path and map variables
|
// create path and map variables
|
||||||
String localVarPath = "/fake";
|
String localVarPath = "/fake";
|
||||||
|
|
||||||
@ -103,18 +103,14 @@ public class FakeApi {
|
|||||||
String[] localVarAuthNames = new String[] { };
|
String[] localVarAuthNames = new String[] { };
|
||||||
return apiClient.buildCall(localVarPath, "PUT", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
|
return apiClient.buildCall(localVarPath, "PUT", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
private com.squareup.okhttp.Call testCodeInjectEndRnNRValidateBeforeCall(String testCodeInjectEndRnNR, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
|
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);
|
com.squareup.okhttp.Call call = testCodeInjectEndRnNRCall(testCodeInjectEndRnNR, progressListener, progressRequestListener);
|
||||||
return call;
|
return call;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -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
|
* @param tempFolderPath Temporary folder path
|
||||||
* @return ApiClient
|
* @return ApiClient
|
||||||
@ -430,6 +430,7 @@ public class ApiClient {
|
|||||||
/**
|
/**
|
||||||
* Sets the connect timeout (in milliseconds).
|
* Sets the connect timeout (in milliseconds).
|
||||||
* A value of 0 means no timeout, otherwise values must be between 1 and
|
* A value of 0 means no timeout, otherwise values must be between 1 and
|
||||||
|
* {@link Integer#MAX_VALUE}.
|
||||||
*
|
*
|
||||||
* @param connectionTimeout connection timeout in milliseconds
|
* @param connectionTimeout connection timeout in milliseconds
|
||||||
* @return Api client
|
* @return Api client
|
||||||
@ -439,6 +440,50 @@ public class ApiClient {
|
|||||||
return this;
|
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.
|
* Format the given parameter object into string.
|
||||||
*
|
*
|
||||||
|
@ -165,7 +165,33 @@ public class ApiClientTest {
|
|||||||
|
|
||||||
apiClient.setConnectTimeout(10000);
|
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
|
@Test
|
||||||
public void testParameterToPairWhenNameIsInvalid() throws Exception {
|
public void testParameterToPairWhenNameIsInvalid() throws Exception {
|
||||||
List<Pair> pairs_a = apiClient.parameterToPair(null, new Integer(1));
|
List<Pair> pairs_a = apiClient.parameterToPair(null, new Integer(1));
|
||||||
|
Loading…
Reference in New Issue
Block a user