Java Code Examples for org.glassfish.jersey.client.RequestEntityProcessing#BUFFERED
The following examples show how to use
org.glassfish.jersey.client.RequestEntityProcessing#BUFFERED .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OAuth2TestUtil.java From datacollector with Apache License 2.0 | 5 votes |
public OAuth2ConfigBean setup(Client client, WebTarget target, Invocation.Builder builder, Response response, OAuth2GrantTypes grantType) { OAuth2ConfigBean configBean = new OAuth2ConfigBean(); MultivaluedMap<String, String> params = new MultivaluedHashMap<>(); RequestEntityProcessing transferEncoding = RequestEntityProcessing.BUFFERED; if (grantType == OAuth2GrantTypes.CLIENT_CREDENTIALS) { params.put(OAuth2ConfigBean.CLIENT_ID_KEY, Collections.singletonList(clientId)); params.put(OAuth2ConfigBean.CLIENT_SECRET_KEY, Collections.singletonList(clientSecret)); params.put(OAuth2ConfigBean.GRANT_TYPE_KEY, Collections.singletonList(OAuth2ConfigBean.CLIENT_CREDENTIALS_GRANT)); configBean.clientId = () -> clientId; configBean.clientSecret = () -> clientSecret; } else { params.put(OAuth2ConfigBean.RESOURCE_OWNER_KEY, Collections.singletonList(clientId)); params.put(OAuth2ConfigBean.PASSWORD_KEY, Collections.singletonList(clientSecret)); params.put(OAuth2ConfigBean.GRANT_TYPE_KEY, Collections.singletonList(OAuth2ConfigBean.RESOURCE_OWNER_GRANT)); configBean.username = () -> clientId; configBean.password = () -> clientSecret; } configBean.credentialsGrantType = grantType; configBean.transferEncoding = RequestEntityProcessing.BUFFERED; configBean.tokenUrl = "https://example.com"; Mockito.when(response.readEntity(String.class)).thenReturn(TOKEN_RESPONSE); Mockito.when(response.getStatus()).thenReturn(200); Mockito.when(builder.post(Mockito.argThat(new FormMatcher(Entity.form(params))))).thenReturn(response); Mockito.when(builder.property(ClientProperties.REQUEST_ENTITY_PROCESSING, transferEncoding)).thenReturn(builder); Mockito.when(builder.header(any(String.class), any(Object.class))).thenReturn(builder); Mockito.when(target.request()).thenReturn(builder); Mockito.when(client.target(configBean.tokenUrl)).thenReturn(target); return configBean; }
Example 2
Source File: HttpClientSourcePaginationIT.java From datacollector with Apache License 2.0 | 5 votes |
private HttpClientConfigBean getHttpClientConfigBean( int start, int limit, PaginationMode mode, boolean keepAllFields ) { HttpClientConfigBean conf = new HttpClientConfigBean(); conf.client.authType = AuthenticationType.NONE; conf.httpMode = HttpClientMode.BATCH; conf.resourceUrl = getBaseUri() + String.format( "paging?pageNum=${startAt}&limit=%d&mode=%s", limit, mode.name() ); conf.client.readTimeoutMillis = 0; conf.client.connectTimeoutMillis = 0; conf.client.transferEncoding = RequestEntityProcessing.BUFFERED; conf.basic.maxBatchSize = 10; conf.basic.maxWaitTime = 10000; conf.pollingInterval = 1000; conf.httpMethod = HttpMethod.GET; conf.dataFormat = DataFormat.JSON; conf.dataFormatConfig.jsonContent = JsonMode.MULTIPLE_OBJECTS; conf.pagination.mode = mode; conf.pagination.startAt = start; conf.pagination.resultFieldPath = "/results"; conf.pagination.rateLimit = 0; conf.pagination.keepAllFields = keepAllFields; conf.pagination.nextPageFieldPath = "/next"; conf.pagination.stopCondition = "${!record:exists('/next')}"; return conf; }