本文整理汇总了Java中org.eclipse.jetty.client.api.Response.Listener方法的典型用法代码示例。如果您正苦于以下问题:Java Response.Listener方法的具体用法?Java Response.Listener怎么用?Java Response.Listener使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jetty.client.api.Response
的用法示例。
在下文中一共展示了Response.Listener方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testGetAccessTokenRequester
import org.eclipse.jetty.client.api.Response; //导入方法依赖的package包/类
@Test
public void testGetAccessTokenRequester()
{
ArgumentCaptor<Jetty92SingleRequester> jetty92SingleRequesterArgumentCaptor = ArgumentCaptor.forClass(Jetty92SingleRequester.class);
Mockito.when(mockJetty92.requestWithRetry(Mockito.any(StringJetty92ResponseEntityReader.class), jetty92SingleRequesterArgumentCaptor.capture())).thenReturn("{\"access_token\": \"access_token\"}");
String accessToken = marketoBaseRestClient.getAccessToken();
Assert.assertEquals("access_token", accessToken);
Jetty92SingleRequester value = jetty92SingleRequesterArgumentCaptor.getValue();
HttpClient client = Mockito.mock(HttpClient.class);
Response.Listener listener = Mockito.mock(Response.Listener.class);
Request mockRequest = Mockito.mock(Request.class);
Mockito.when(client.newRequest(Mockito.eq(IDENTITY_END_POINT + MarketoRESTEndpoint.ACCESS_TOKEN.getEndpoint()))).thenReturn(mockRequest);
Request request1 = Mockito.mock(Request.class);
Mockito.when(mockRequest.method(Mockito.eq(HttpMethod.GET))).thenReturn(request1);
value.requestOnce(client, listener);
Mockito.verify(request1, Mockito.times(1)).param(Mockito.eq("client_id"), Mockito.eq("clientId"));
Mockito.verify(request1, Mockito.times(1)).param(Mockito.eq("client_secret"), Mockito.eq("clientSecret"));
Mockito.verify(request1, Mockito.times(1)).param(Mockito.eq("grant_type"), Mockito.eq("client_credentials"));
Assert.assertTrue(value.toRetry(createHttpResponseException(502)));
}
示例2: testDoRequestRequester
import org.eclipse.jetty.client.api.Response; //导入方法依赖的package包/类
@Test
public void testDoRequestRequester() throws Exception
{
MarketoBaseRestClient spy = Mockito.spy(marketoBaseRestClient);
StringContentProvider contentProvider = new StringContentProvider("Content", StandardCharsets.UTF_8);
ArgumentCaptor<Jetty92SingleRequester> jetty92SingleRequesterArgumentCaptor = ArgumentCaptor.forClass(Jetty92SingleRequester.class);
MarketoResponse<Object> expectedMarketoResponse = new MarketoResponse<>();
Mockito.when(mockJetty92.requestWithRetry(Mockito.any(MarketoResponseJetty92EntityReader.class), jetty92SingleRequesterArgumentCaptor.capture())).thenReturn(expectedMarketoResponse);
Mockito.when(mockJetty92.requestWithRetry(Mockito.any(StringJetty92ResponseEntityReader.class), Mockito.any(Jetty92SingleRequester.class))).thenReturn("{\"access_token\": \"access_token\"}");
String target = "target";
HashMap<String, String> headers = Maps.<String, String>newHashMap();
headers.put("testHeader1", "testHeaderValue1");
ImmutableListMultimap<String, String> build = new ImmutableListMultimap.Builder<String, String>().put("param", "param1").build();
MarketoResponse<Object> marketoResponse = spy.doRequest(target, HttpMethod.POST, headers, build, contentProvider, new MarketoResponseJetty92EntityReader<Object>(10));
HttpClient client = Mockito.mock(HttpClient.class);
Response.Listener listener = Mockito.mock(Response.Listener.class);
Request mockRequest = Mockito.mock(Request.class);
Mockito.when(client.newRequest(Mockito.eq(target))).thenReturn(mockRequest);
Mockito.when(mockRequest.method(Mockito.eq(HttpMethod.POST))).thenReturn(mockRequest);
Jetty92SingleRequester jetty92SingleRequester = jetty92SingleRequesterArgumentCaptor.getValue();
jetty92SingleRequester.requestOnce(client, listener);
Assert.assertEquals(expectedMarketoResponse, marketoResponse);
Mockito.verify(mockRequest, Mockito.times(1)).header(Mockito.eq("testHeader1"), Mockito.eq("testHeaderValue1"));
Mockito.verify(mockRequest, Mockito.times(1)).header(Mockito.eq("Authorization"), Mockito.eq("Bearer access_token"));
Mockito.verify(mockRequest, Mockito.times(1)).param(Mockito.eq("param"), Mockito.eq("param1"));
Mockito.verify(mockRequest, Mockito.times(1)).content(Mockito.eq(contentProvider));
}
示例3: testDoRequesterRetry
import org.eclipse.jetty.client.api.Response; //导入方法依赖的package包/类
@Test
public void testDoRequesterRetry() throws Exception
{
MarketoBaseRestClient spy = Mockito.spy(marketoBaseRestClient);
ArgumentCaptor<Jetty92SingleRequester> jetty92SingleRequesterArgumentCaptor = ArgumentCaptor.forClass(Jetty92SingleRequester.class);
Mockito.when(mockJetty92.requestWithRetry(Mockito.any(MarketoResponseJetty92EntityReader.class), jetty92SingleRequesterArgumentCaptor.capture())).thenReturn(new MarketoResponse<>());
Mockito.when(mockJetty92.requestWithRetry(Mockito.any(StringJetty92ResponseEntityReader.class), Mockito.any(Jetty92SingleRequester.class))).thenReturn("{\"access_token\": \"access_token\"}");
spy.doRequest("", HttpMethod.POST, null, null, null, new MarketoResponseJetty92EntityReader<Object>(10));
HttpClient client = Mockito.mock(HttpClient.class);
Response.Listener listener = Mockito.mock(Response.Listener.class);
Request mockRequest = Mockito.mock(Request.class);
Mockito.when(client.newRequest(Mockito.anyString())).thenReturn(mockRequest);
Mockito.when(mockRequest.method(Mockito.eq(HttpMethod.POST))).thenReturn(mockRequest);
Jetty92SingleRequester jetty92SingleRequester = jetty92SingleRequesterArgumentCaptor.getValue();
jetty92SingleRequester.requestOnce(client, listener);
Assert.assertTrue(jetty92SingleRequester.toRetry(createHttpResponseException(502)));
Assert.assertFalse(jetty92SingleRequester.toRetry(createHttpResponseException(400)));
Assert.assertFalse(jetty92SingleRequester.toRetry(createMarketoAPIException("ERR", "ERR")));
Assert.assertTrue(jetty92SingleRequester.toRetry(createMarketoAPIException("606", "")));
Assert.assertTrue(jetty92SingleRequester.toRetry(createMarketoAPIException("615", "")));
Assert.assertTrue(jetty92SingleRequester.toRetry(createMarketoAPIException("602", "")));
Mockito.verify(mockJetty92, Mockito.times(2)).requestWithRetry(Mockito.any(StringJetty92ResponseEntityReader.class), Mockito.any(Jetty92SingleRequester.class));
}
示例4: newProxyResponseListener
import org.eclipse.jetty.client.api.Response; //导入方法依赖的package包/类
protected Response.Listener newProxyResponseListener(HttpServletRequest request, HttpServletResponse response) {
return new ProxyResponseListener(request, response);
}
示例5: getResponseListener
import org.eclipse.jetty.client.api.Response; //导入方法依赖的package包/类
@Override
public Response.Listener getResponseListener() {
return new SecurityListener(maxContentLength);
}
示例6: getListener
import org.eclipse.jetty.client.api.Response; //导入方法依赖的package包/类
@Override
public Response.Listener getListener()
{
this.listener = new InputStreamResponseListener();
return this.listener;
}
开发者ID:treasure-data,项目名称:embulk-input-marketo,代码行数:7,代码来源:MarketoInputStreamResponseEntityReader.java