当前位置: 首页>>代码示例>>Java>>正文


Java DeleteMethod.releaseConnection方法代码示例

本文整理汇总了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());
}
 
开发者ID:lorthos,项目名称:incubator-zeppelin-druid,代码行数:21,代码来源:ZeppelinRestApiTest.java

示例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);
}
 
开发者ID:apache,项目名称:zeppelin,代码行数:21,代码来源:ZeppelinRestApiTest.java

示例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();
}
 
开发者ID:apache,项目名称:zeppelin,代码行数:17,代码来源:InterpreterRestApiTest.java

示例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);
}
 
开发者ID:huihoo,项目名称:olat,代码行数:21,代码来源:UserAuthenticationMgmtITCase.java

示例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()));
    }
}
 
开发者ID:huihoo,项目名称:olat,代码行数:17,代码来源:CatalogITCase.java

示例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);
}
 
开发者ID:huihoo,项目名称:olat,代码行数:23,代码来源:CatalogITCase.java

示例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;
  }
}
 
开发者ID:linkedin,项目名称:pinot,代码行数:30,代码来源:SchemaUtils.java

示例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 );
}
 
开发者ID:koles,项目名称:gooddata-agent,代码行数:22,代码来源:GdcRESTApiWrapper.java

示例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();
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:19,代码来源:Client.java

示例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();
  }
}
 
开发者ID:inbravo,项目名称:scribe,代码行数:36,代码来源:HTTPClient.java

示例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");

}
 
开发者ID:wso2,项目名称:product-ei,代码行数:29,代码来源:ESBJAVA4852URITemplateWithCompleteURLTestCase.java

示例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();
}
 
开发者ID:lorthos,项目名称:incubator-zeppelin-druid,代码行数:31,代码来源:ZeppelinRestApiTest.java

示例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);
    }
  }
 
开发者ID:lorthos,项目名称:incubator-zeppelin-druid,代码行数:13,代码来源:ZeppelinRestApiTest.java

示例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);
  }
}
 
开发者ID:apache,项目名称:zeppelin,代码行数:11,代码来源:NotebookSecurityRestApiTest.java

示例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);
    }
  }
 
开发者ID:apache,项目名称:zeppelin,代码行数:13,代码来源:ZeppelinRestApiTest.java


注:本文中的org.apache.commons.httpclient.methods.DeleteMethod.releaseConnection方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。