@Test public void testGet() { handler.authenticate(); handler.addRequest("GET", "/qcbin/rest/domains/domain/projects/project/path/arg1/arg2", 200) .responseHeader("custom", "value") .responseBody("result"); AliRestClient client = AliRestClient.create(handler.getQcUrl(), "domain", "project", "user", "password", RestClient.SessionStrategy.AUTO_LOGIN); ResultInfo resultInfo = ResultInfo.create(new ByteArrayOutputStream()); int code = client.get(resultInfo, "/path/{0}/{1}", "arg1", "arg2"); Assert.assertEquals(200, code); Assert.assertEquals("result", resultInfo.getBodyStream().toString()); Assert.assertEquals("value", resultInfo.getHeaders().get("custom")); }
@Override public int get(ResultInfo result, String template, Object... params) { GetMethod method = createMethod(domain, project, GET_BUILDER, null, template, params); executeHttpMethod(method, result); return result.getHttpStatus(); }
AliRestClient implements RestClient { @Override public int get(ResultInfo result, String template, Object... params) { GetMethod method = createMethod(domain, project, GET_BUILDER, null, template, params); executeHttpMethod(method, result); return result.getHttpStatus(); } }
AliRestClient implements RestClient { @Override public int get(ResultInfo result, String template, Object... params) { GetMethod method = createMethod(domain, project, GET_BUILDER, null, template, params); executeHttpMethod(method, result); return result.getHttpStatus(); } private  AliRestClient(String location, String domain, String project,
                          String userName, String password,
                          SessionStrategy sessionStrategy); }
AliRestClient implements RestClient { @Override public int get(ResultInfo result, String template, Object... params) { GetMethod method = createMethod(domain, project, GET_BUILDER, null, template, params); executeHttpMethod(method, 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 get(ResultInfo result, String template, Object... params) { GetMethod method = createMethod(domain, project, GET_BUILDER, null, template, params); executeHttpMethod(method, 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; }