本文整理汇总了Java中org.apache.commons.httpclient.methods.DeleteMethod.releaseConnection方法的典型用法代码示例。如果您正苦于以下问题:Java DeleteMethod.releaseConnection方法的具体用法?Java DeleteMethod.releaseConnection怎么用?Java DeleteMethod.releaseConnection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.httpclient.methods.DeleteMethod
的用法示例。
在下文中一共展示了DeleteMethod.releaseConnection方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testDeleteParagraph
import org.apache.commons.httpclient.methods.DeleteMethod; //导入方法依赖的package包/类
@Test
public void testDeleteParagraph() throws IOException {
Note note = ZeppelinServer.notebook.createNote();
Paragraph p = note.addParagraph();
p.setTitle("title1");
p.setText("text1");
note.persist();
DeleteMethod delete = httpDelete("/notebook/" + note.getId() + "/paragraph/" + p.getId());
assertThat("Test delete method: ", delete, isAllowed());
delete.releaseConnection();
Note retrNote = ZeppelinServer.notebook.getNote(note.getId());
Paragraph retrParagrah = retrNote.getParagraph(p.getId());
assertNull("paragraph should be deleted", retrParagrah);
ZeppelinServer.notebook.removeNote(note.getId());
}
示例2: testDeleteParagraph
import org.apache.commons.httpclient.methods.DeleteMethod; //导入方法依赖的package包/类
@Test
public void testDeleteParagraph() throws IOException {
Note note = ZeppelinServer.notebook.createNote(anonymous);
Paragraph p = note.addNewParagraph(AuthenticationInfo.ANONYMOUS);
p.setTitle("title1");
p.setText("text1");
note.persist(anonymous);
DeleteMethod delete = httpDelete("/notebook/" + note.getId() + "/paragraph/" + p.getId());
assertThat("Test delete method: ", delete, isAllowed());
delete.releaseConnection();
Note retrNote = ZeppelinServer.notebook.getNote(note.getId());
Paragraph retrParagrah = retrNote.getParagraph(p.getId());
assertNull("paragraph should be deleted", retrParagrah);
ZeppelinServer.notebook.removeNote(note.getId(), anonymous);
}
示例3: testAddDeleteRepository
import org.apache.commons.httpclient.methods.DeleteMethod; //导入方法依赖的package包/类
@Test
public void testAddDeleteRepository() throws IOException {
// Call create repository API
String repoId = "securecentral";
String jsonRequest = "{\"id\":\"" + repoId +
"\",\"url\":\"https://repo1.maven.org/maven2\",\"snapshot\":\"false\"}";
PostMethod post = httpPost("/interpreter/repository/", jsonRequest);
assertThat("Test create method:", post, isAllowed());
post.releaseConnection();
// Call delete repository API
DeleteMethod delete = httpDelete("/interpreter/repository/" + repoId);
assertThat("Test delete method:", delete, isAllowed());
delete.releaseConnection();
}
示例4: testDeleteAuthentications
import org.apache.commons.httpclient.methods.DeleteMethod; //导入方法依赖的package包/类
@Test
public void testDeleteAuthentications() throws IOException {
final HttpClient c = loginWithCookie("administrator", "olat");
// create an authentication token
final Identity adminIdent = baseSecurity.findIdentityByName("administrator");
final Authentication authentication = baseSecurity.createAndPersistAuthentication(adminIdent, "REST-A-2", "administrator", "credentials");
assertTrue(authentication != null && authentication.getKey() != null && authentication.getKey().longValue() > 0);
DBFactory.getInstance().intermediateCommit();
// delete an authentication token
final String request = "/users/administrator/auth/" + authentication.getKey().toString();
final DeleteMethod method = createDelete(request, MediaType.APPLICATION_XML, true);
final int code = c.executeMethod(method);
assertEquals(code, 200);
method.releaseConnection();
final Authentication refAuth = baseSecurity.findAuthentication(adminIdent, "REST-A-2");
assertNull(refAuth);
}
示例5: testDeleteCatalogEntry
import org.apache.commons.httpclient.methods.DeleteMethod; //导入方法依赖的package包/类
@Test
public void testDeleteCatalogEntry() throws IOException {
final HttpClient c = loginWithCookie("administrator", "olat");
final URI uri = UriBuilder.fromUri(getContextURI()).path("catalog").path(entry2.getKey().toString()).build();
final DeleteMethod method = createDelete(uri, MediaType.APPLICATION_JSON, true);
final int code = c.executeMethod(method);
assertEquals(200, code);
method.releaseConnection();
final List<CatalogEntry> entries = catalogService.getChildrenOf(root1);
for (final CatalogEntry entry : entries) {
assertFalse(entry.getKey().equals(entry2.getKey()));
}
}
示例6: testRemoveOwner
import org.apache.commons.httpclient.methods.DeleteMethod; //导入方法依赖的package包/类
@Test
public void testRemoveOwner() throws IOException {
final HttpClient c = loginWithCookie("administrator", "olat");
final URI uri = UriBuilder.fromUri(getContextURI()).path("catalog").path(entry1.getKey().toString()).path("owners").path(id1.getUser().getKey().toString())
.build();
final DeleteMethod method = createDelete(uri, MediaType.APPLICATION_JSON, true);
final int code = c.executeMethod(method);
method.releaseConnection();
assertEquals(200, code);
final CatalogEntry entry = catalogService.loadCatalogEntry(entry1.getKey());
final List<Identity> identities = securityManager.getIdentitiesOfSecurityGroup(entry.getOwnerGroup());
boolean found = false;
for (final Identity identity : identities) {
if (identity.getKey().equals(id1.getKey())) {
found = true;
}
}
assertFalse(found);
}
示例7: deleteSchema
import org.apache.commons.httpclient.methods.DeleteMethod; //导入方法依赖的package包/类
/**
* Given host, port and schema name, send a http DELETE request to delete the {@link Schema}.
*
* @return <code>true</code> on success.
* <P><code>false</code> on failure.
*/
public static boolean deleteSchema(@Nonnull String host, int port, @Nonnull String schemaName) {
Preconditions.checkNotNull(host);
Preconditions.checkNotNull(schemaName);
try {
URL url = new URL("http", host, port, "/schemas/" + schemaName);
DeleteMethod httpDelete = new DeleteMethod(url.toString());
try {
int responseCode = HTTP_CLIENT.executeMethod(httpDelete);
if (responseCode >= 400) {
String response = httpDelete.getResponseBodyAsString();
LOGGER.warn("Got error response code: {}, response: {}", responseCode, response);
return false;
}
return true;
} finally {
httpDelete.releaseConnection();
}
} catch (Exception e) {
LOGGER.error("Caught exception while getting the schema: {} from host: {}, port: {}", schemaName, host, port, e);
return false;
}
}
示例8: logout
import org.apache.commons.httpclient.methods.DeleteMethod; //导入方法依赖的package包/类
/**
* GDC logout - remove active session, if any exists
*
* @throws HttpMethodException
*/
public void logout() throws HttpMethodException {
if (userLogin == null)
return;
l.debug("Logging out.");
DeleteMethod logoutDelete = createDeleteMethod(getServerUrl() + userLogin.getString("state"));
try {
String resp = executeMethodOk(logoutDelete, false); // do not re-login on SC_UNAUTHORIZED
userLogin = null;
profile = null;
l.debug("Successfully logged out.");
} finally {
logoutDelete.releaseConnection();
}
this.client = new HttpClient();
NetUtil.configureHttpProxy( client );
}
示例9: delete
import org.apache.commons.httpclient.methods.DeleteMethod; //导入方法依赖的package包/类
/**
* Send a DELETE request
* @param cluster the cluster definition
* @param path the path or URI
* @return a Response object with response detail
* @throws IOException
*/
public Response delete(Cluster cluster, String path) throws IOException {
DeleteMethod method = new DeleteMethod();
try {
int code = execute(cluster, method, null, path);
Header[] headers = method.getResponseHeaders();
byte[] content = method.getResponseBody();
return new Response(code, headers, content);
} finally {
method.releaseConnection();
}
}
示例10: deleteAccount
import org.apache.commons.httpclient.methods.DeleteMethod; //导入方法依赖的package包/类
private static void deleteAccount() throws HttpException, IOException, Exception {
System.out.println("Sent HTTP DELETE request to delete Account");
String accountId = null;
DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
Document doc = docBuilder.parse(new File(testFolder + "Account.xml"));
NodeList nodeList = doc.getElementsByTagName("Id");
if (nodeList != null) {
for (int i = 0; i <= nodeList.getLength(); i++) {
Node accountIdNode = nodeList.item(i);
if (accountIdNode != null) {
System.out.println("Account Id " + accountIdNode.getTextContent());
accountId = accountIdNode.getTextContent();
}
}
}
URL url = null;
try {
url = new URL(cadURL + "/object/account/" + accountId + "?_type=xml&agent=sfdcten~~ag1");
} catch (MalformedURLException mue) {
System.err.println(mue);
}
DeleteMethod delete = new DeleteMethod(url.toString());
HttpClient httpclient = new HttpClient();
try {
System.out.println("URI: " + delete.getURI());
int result = httpclient.executeMethod(delete);
System.out.println("Response status code: " + result);
System.out.println("Response body: " + delete.getResponseBodyAsString());
} finally {
delete.releaseConnection();
}
}
示例11: testCompleteURLWithHTTPMethod
import org.apache.commons.httpclient.methods.DeleteMethod; //导入方法依赖的package包/类
@Test(groups = {"wso2.esb"}, description = "Sending complete URL to API and for dispatching")
public void testCompleteURLWithHTTPMethod() throws Exception {
DeleteMethod delete = new DeleteMethod(getApiInvocationURL("myApi1/order/21441/item/17440079" +
"?message_id=41ec2ec4-e629-4e04-9fdf-c32e97b35bd1"));
HttpClient httpClient = new HttpClient();
LogViewerClient logViewerClient = new LogViewerClient(contextUrls.getBackEndUrl(), getSessionCookie());
logViewerClient.clearLogs();
try {
httpClient.executeMethod(delete);
Assert.assertEquals(delete.getStatusLine().getStatusCode(), 202, "Response code mismatched");
} finally {
delete.releaseConnection();
}
LogEvent[] logEvents = logViewerClient.getAllRemoteSystemLogs();
boolean isLogMessageFound = false;
for (LogEvent log : logEvents) {
if (log != null && log.getMessage().contains("order API INVOKED")) {
isLogMessageFound = true;
break;
}
}
Assert.assertTrue(isLogMessageFound, "Request Not Dispatched to API when HTTP method having full url");
}
示例12: testSettingsCRUD
import org.apache.commons.httpclient.methods.DeleteMethod; //导入方法依赖的package包/类
@Test
public void testSettingsCRUD() throws IOException {
// Call Create Setting REST API
String jsonRequest = "{\"name\":\"md2\",\"group\":\"md\",\"properties\":{\"propname\":\"propvalue\"},\"" +
"interpreterGroup\":[{\"class\":\"org.apache.zeppelin.markdown.Markdown\",\"name\":\"md\"}]}";
PostMethod post = httpPost("/interpreter/setting/", jsonRequest);
LOG.info("testSettingCRUD create response\n" + post.getResponseBodyAsString());
assertThat("test create method:", post, isCreated());
Map<String, Object> resp = gson.fromJson(post.getResponseBodyAsString(), new TypeToken<Map<String, Object>>() {
}.getType());
Map<String, Object> body = (Map<String, Object>) resp.get("body");
//extract id from body string {id=2AWMQDNX7, name=md2, group=md,
String newSettingId = body.toString().split(",")[0].split("=")[1];
post.releaseConnection();
// Call Update Setting REST API
jsonRequest = "{\"name\":\"md2\",\"group\":\"md\",\"properties\":{\"propname\":\"Otherpropvalue\"},\"" +
"interpreterGroup\":[{\"class\":\"org.apache.zeppelin.markdown.Markdown\",\"name\":\"md\"}]}";
PutMethod put = httpPut("/interpreter/setting/" + newSettingId, jsonRequest);
LOG.info("testSettingCRUD update response\n" + put.getResponseBodyAsString());
assertThat("test update method:", put, isAllowed());
put.releaseConnection();
// Call Delete Setting REST API
DeleteMethod delete = httpDelete("/interpreter/setting/" + newSettingId);
LOG.info("testSettingCRUD delete response\n" + delete.getResponseBodyAsString());
assertThat("Test delete method:", delete, isAllowed());
delete.releaseConnection();
}
示例13: testDeleteNotebook
import org.apache.commons.httpclient.methods.DeleteMethod; //导入方法依赖的package包/类
private void testDeleteNotebook(String notebookId) throws IOException {
DeleteMethod delete = httpDelete(("/notebook/" + notebookId));
LOG.info("testDeleteNotebook delete response\n" + delete.getResponseBodyAsString());
assertThat("Test delete method:", delete, isAllowed());
delete.releaseConnection();
// make sure note is deleted
if (!notebookId.isEmpty()) {
Note deletedNote = ZeppelinServer.notebook.getNote(notebookId);
assertNull("Deleted note should be null", deletedNote);
}
}
示例14: deleteNoteForUser
import org.apache.commons.httpclient.methods.DeleteMethod; //导入方法依赖的package包/类
private void deleteNoteForUser(String noteId, String user, String pwd) throws IOException {
DeleteMethod delete = httpDelete(("/notebook/" + noteId), user, pwd);
assertThat("Test delete method:", delete, isAllowed());
delete.releaseConnection();
// make sure note is deleted
if (!noteId.isEmpty()) {
Note deletedNote = ZeppelinServer.notebook.getNote(noteId);
assertNull("Deleted note should be null", deletedNote);
}
}
示例15: testDeleteNote
import org.apache.commons.httpclient.methods.DeleteMethod; //导入方法依赖的package包/类
private void testDeleteNote(String noteId) throws IOException {
DeleteMethod delete = httpDelete(("/notebook/" + noteId));
LOG.info("testDeleteNote delete response\n" + delete.getResponseBodyAsString());
assertThat("Test delete method:", delete, isAllowed());
delete.releaseConnection();
// make sure note is deleted
if (!noteId.isEmpty()) {
Note deletedNote = ZeppelinServer.notebook.getNote(noteId);
assertNull("Deleted note should be null", deletedNote);
}
}