@Test public void testPost() { handler.authenticate(); handler.addRequest("POST", "/qcbin/rest/domains/domain/projects/project/path/arg1/arg2", 200) .expectHeader("header-input", "value-input") .expectBody("input") .responseHeader("header-output", "value-output") .responseBody("output"); AliRestClient client = AliRestClient.create(handler.getQcUrl(), "domain", "project", "user", "password", RestClient.SessionStrategy.AUTO_LOGIN); ResultInfo resultInfo = ResultInfo.create(new ByteArrayOutputStream()); int code = client.post(InputData.create("input", Collections.singletonMap("header-input", "value-input")), resultInfo, "/path/{0}/{1}", "arg1", "arg2"); Assert.assertEquals(200, code); Assert.assertEquals("output", resultInfo.getBodyStream().toString()); Assert.assertEquals("value-output", resultInfo.getHeaders().get("header-output")); }
@Override public int post(InputData data, ResultInfo result, String template, Object... params) { PostMethod postMethod = createMethod(domain, project, POST_BUILDER, createRequestEntity(data), template, params); setHeaders(postMethod, data.getHeaders()); executeHttpMethod(postMethod, result); return result.getHttpStatus(); }
AliRestClient implements RestClient { @Override public int post(InputData data, ResultInfo result, String template, Object... params) { PostMethod postMethod = createMethod(domain, project, POST_BUILDER, createRequestEntity(data), template, params); setHeaders(postMethod, data.getHeaders()); executeHttpMethod(postMethod, result); return result.getHttpStatus(); } }
AliRestClient implements RestClient { @Override public int post(InputData data, ResultInfo result, String template, Object... params) { PostMethod postMethod = createMethod(domain, project, POST_BUILDER, createRequestEntity(data), template, params); setHeaders(postMethod, data.getHeaders()); executeHttpMethod(postMethod, result); return result.getHttpStatus(); } private  AliRestClient(String location, String domain, String project,
                          String userName, String password,
                          SessionStrategy sessionStrategy); }
AliRestClient implements RestClient { @Override public int post(InputData data, ResultInfo result, String template, Object... params) { PostMethod postMethod = createMethod(domain, project, POST_BUILDER, createRequestEntity(data), template, params); setHeaders(postMethod, data.getHeaders()); executeHttpMethod(postMethod, result); return result.getHttpStatus(); } private  AliRestClient(String location, String domain, String project,
                          String userName, String password,
                          SessionStrategy sessionStrategy); static AliRestClient create(String location, String domain, String project, String userName, String password, SessionStrategy sessionStrategy); @Override void setTimeout(int timeout); @Override void setHttpProxy(String proxyHost, int proxyPort); @Override void setHttpProxyCredentials(String username, String password); @Override String getEncoding(); @Override SessionStrategy getSessionStrategy(); @Override void setEncoding(String encoding); @Override void setDomain(String domain); @Override void setProject(String project); @Override String getDomain(); @Override String getProject(); @Override List<Cookie> getCookies(String cookieName); @Override synchronized void login(); @Override synchronized void logout(); @Override String getForString(String template, Object... params); @Override InputStream getForStream(String template, Object... params); @Override int get(ResultInfo result, String template, Object... params); @Override int put(InputData inputData, ResultInfo result, String template, Object... params); @Override int delete(ResultInfo result, String template, Object... params); @Override int post(InputData data, ResultInfo result, String template, Object... params); @Override List<String> listDomains(); @Override List<String> listCurrentProjects(); }
AliRestClient implements RestClient { @Override public int post(InputData data, ResultInfo result, String template, Object... params) { PostMethod postMethod = createMethod(domain, project, POST_BUILDER, createRequestEntity(data), template, params); setHeaders(postMethod, data.getHeaders()); executeHttpMethod(postMethod, result); return result.getHttpStatus(); } private  AliRestClient(String location, String domain, String project,
                          String userName, String password,
                          SessionStrategy sessionStrategy); static AliRestClient create(String location, String domain, String project, String userName, String password, SessionStrategy sessionStrategy); @Override void setTimeout(int timeout); @Override void setHttpProxy(String proxyHost, int proxyPort); @Override void setHttpProxyCredentials(String username, String password); @Override String getEncoding(); @Override SessionStrategy getSessionStrategy(); @Override void setEncoding(String encoding); @Override void setDomain(String domain); @Override void setProject(String project); @Override String getDomain(); @Override String getProject(); @Override List<Cookie> getCookies(String cookieName); @Override synchronized void login(); @Override synchronized void logout(); @Override String getForString(String template, Object... params); @Override InputStream getForStream(String template, Object... params); @Override int get(ResultInfo result, String template, Object... params); @Override int put(InputData inputData, ResultInfo result, String template, Object... params); @Override int delete(ResultInfo result, String template, Object... params); @Override int post(InputData data, ResultInfo result, String template, Object... params); @Override List<String> listDomains(); @Override List<String> listCurrentProjects(); static final Set<Integer> AUTH_FAIL_STATUSES; static final int DEFAULT_CLIENT_TIMEOUT; }