use of org.apache.commons.httpclient.methods.GetMethod in project zeppelin by apache.
the class NotebookRestApiTest method testClearAllParagraphOutput.
@Test
public void testClearAllParagraphOutput() throws IOException {
// Create note and set result explicitly
Note note = ZeppelinServer.notebook.createNote(anonymous);
Paragraph p1 = note.addParagraph(AuthenticationInfo.ANONYMOUS);
InterpreterResult result = new InterpreterResult(InterpreterResult.Code.SUCCESS, InterpreterResult.Type.TEXT, "result");
p1.setResult(result);
Paragraph p2 = note.addParagraph(AuthenticationInfo.ANONYMOUS);
p2.setReturn(result, new Throwable());
// clear paragraph result
PutMethod put = httpPut("/notebook/" + note.getId() + "/clear", "");
LOG.info("test clear paragraph output response\n" + put.getResponseBodyAsString());
assertThat(put, isAllowed());
put.releaseConnection();
// check if paragraph results are cleared
GetMethod get = httpGet("/notebook/" + note.getId() + "/paragraph/" + p1.getId());
assertThat(get, isAllowed());
Map<String, Object> resp1 = gson.fromJson(get.getResponseBodyAsString(), new TypeToken<Map<String, Object>>() {
}.getType());
Map<String, Object> resp1Body = (Map<String, Object>) resp1.get("body");
assertNull(resp1Body.get("result"));
get = httpGet("/notebook/" + note.getId() + "/paragraph/" + p2.getId());
assertThat(get, isAllowed());
Map<String, Object> resp2 = gson.fromJson(get.getResponseBodyAsString(), new TypeToken<Map<String, Object>>() {
}.getType());
Map<String, Object> resp2Body = (Map<String, Object>) resp2.get("body");
assertNull(resp2Body.get("result"));
get.releaseConnection();
//cleanup
ZeppelinServer.notebook.removeNote(note.getId(), anonymous);
}
use of org.apache.commons.httpclient.methods.GetMethod in project zeppelin by apache.
the class AbstractTestRestApi method httpGet.
protected static GetMethod httpGet(String path, String user, String pwd) throws IOException {
LOG.info("Connecting to {}", url + path);
HttpClient httpClient = new HttpClient();
GetMethod getMethod = new GetMethod(url + path);
getMethod.addRequestHeader("Origin", url);
if (userAndPasswordAreNotBlank(user, pwd)) {
getMethod.setRequestHeader("Cookie", "JSESSIONID=" + getCookie(user, pwd));
}
httpClient.executeMethod(getMethod);
LOG.info("{} - {}", getMethod.getStatusCode(), getMethod.getStatusText());
return getMethod;
}
use of org.apache.commons.httpclient.methods.GetMethod in project zeppelin by apache.
the class ConfigurationsRestApiTest method testGetAll.
@Test
public void testGetAll() throws IOException {
GetMethod get = httpGet("/configurations/all");
Map<String, Object> resp = gson.fromJson(get.getResponseBodyAsString(), new TypeToken<Map<String, Object>>() {
}.getType());
Map<String, String> body = (Map<String, String>) resp.get("body");
assertTrue(body.size() > 0);
// it shouldn't have key/value pair which key contains "password"
assertTrue(Iterators.all(body.keySet().iterator(), new Predicate<String>() {
@Override
public boolean apply(String key) {
return !key.contains("password");
}
}));
}
use of org.apache.commons.httpclient.methods.GetMethod in project zeppelin by apache.
the class ConfigurationsRestApiTest method testGetViaPrefix.
@Test
public void testGetViaPrefix() throws IOException {
final String prefix = "zeppelin.server";
GetMethod get = httpGet("/configurations/prefix/" + prefix);
Map<String, Object> resp = gson.fromJson(get.getResponseBodyAsString(), new TypeToken<Map<String, Object>>() {
}.getType());
Map<String, String> body = (Map<String, String>) resp.get("body");
assertTrue(body.size() > 0);
assertTrue(Iterators.all(body.keySet().iterator(), new Predicate<String>() {
@Override
public boolean apply(String key) {
return !key.contains("password") && key.startsWith(prefix);
}
}));
}
use of org.apache.commons.httpclient.methods.GetMethod in project zeppelin by apache.
the class InterpreterRestApiTest method testListRepository.
@Test
public void testListRepository() throws IOException {
GetMethod get = httpGet("/interpreter/repository");
assertThat(get, isAllowed());
get.releaseConnection();
}
Aggregations