@Test public void testGetForStream() throws IOException { handler.authenticate(); handler.addRequest("GET", "/qcbin/rest/domains/domain/projects/project/path/arg1/arg2", 200) .responseBody("result"); AliRestClient client = AliRestClient.create(handler.getQcUrl(), "domain", "project", "user", "password", RestClient.SessionStrategy.AUTO_LOGIN); InputStream result = client.getForStream("/path/{0}/{1}", "arg1", "arg2"); Assert.assertEquals("result", IOUtils.toString(result)); }
@Override public InputStream getForStream(String template, Object... params) { ByteArrayOutputStream responseBody = new ByteArrayOutputStream(); ResultInfo result = ResultInfo.create(responseBody); get(result, template, params); HttpStatusBasedException.throwForError(result); return new ByteArrayInputStream(responseBody.toByteArray()); }
AliRestClient implements RestClient { @Override public InputStream getForStream(String template, Object... params) { ByteArrayOutputStream responseBody = new ByteArrayOutputStream(); ResultInfo result = ResultInfo.create(responseBody); get(result, template, params); HttpStatusBasedException.throwForError(result); return new ByteArrayInputStream(responseBody.toByteArray()); } }
AliRestClient implements RestClient { @Override public InputStream getForStream(String template, Object... params) { ByteArrayOutputStream responseBody = new ByteArrayOutputStream(); ResultInfo result = ResultInfo.create(responseBody); get(result, template, params); HttpStatusBasedException.throwForError(result); return new ByteArrayInputStream(responseBody.toByteArray()); } private  AliRestClient(String location, String domain, String project,
                          String userName, String password,
                          SessionStrategy sessionStrategy); }
AliRestClient implements RestClient { @Override public InputStream getForStream(String template, Object... params) { ByteArrayOutputStream responseBody = new ByteArrayOutputStream(); ResultInfo result = ResultInfo.create(responseBody); get(result, template, params); HttpStatusBasedException.throwForError(result); return new ByteArrayInputStream(responseBody.toByteArray()); } 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 InputStream getForStream(String template, Object... params) { ByteArrayOutputStream responseBody = new ByteArrayOutputStream(); ResultInfo result = ResultInfo.create(responseBody); get(result, template, params); HttpStatusBasedException.throwForError(result); return new ByteArrayInputStream(responseBody.toByteArray()); } 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; }