當前位置: 首頁>>代碼示例>>Java>>正文


Java HttpMethod.POST屬性代碼示例

本文整理匯總了Java中org.springframework.http.HttpMethod.POST屬性的典型用法代碼示例。如果您正苦於以下問題:Java HttpMethod.POST屬性的具體用法?Java HttpMethod.POST怎麽用?Java HttpMethod.POST使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在org.springframework.http.HttpMethod的用法示例。


在下文中一共展示了HttpMethod.POST屬性的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getToken

public OAuth2Token getToken(String authorizationCode) {
    RestTemplate rest = new RestTemplate();
    String authBase64 = configuration.encodeCredentials("clientapp",
            "123456");

    RequestEntity<MultiValueMap<String, String>> requestEntity = new RequestEntity<>(
        configuration.getBody(authorizationCode),
        configuration.getHeader(authBase64), HttpMethod.POST,
        URI.create("http://localhost:8080/oauth/token"));

    ResponseEntity<OAuth2Token> responseEntity = rest.exchange(
            requestEntity, OAuth2Token.class);

    if (responseEntity.getStatusCode().is2xxSuccessful()) {
        return responseEntity.getBody();
    }

    throw new RuntimeException("error trying to retrieve access token");
}
 
開發者ID:PacktPublishing,項目名稱:OAuth-2.0-Cookbook,代碼行數:19,代碼來源:AuthorizationCodeTokenService.java

示例2: testNotReady

@Test
public void testNotReady() throws IOException {
  String exceptionMessage = "System is not ready for remote calls. "
      + "When beans are making remote calls in initialization, it's better to "
      + "implement " + BootListener.class.getName() + " and do it after EventType.AFTER_REGISTRY.";

  ReferenceConfigUtils.setReady(false);
  CseClientHttpRequest client =
      new CseClientHttpRequest(URI.create("cse://app:test/"), HttpMethod.POST);

  try {
    client.execute();
    Assert.fail("must throw exception");
  } catch (IllegalStateException e) {
    Assert.assertEquals(exceptionMessage, e.getMessage());
  }
}
 
開發者ID:apache,項目名稱:incubator-servicecomb-java-chassis,代碼行數:17,代碼來源:TestCseClientHttpRequest.java

示例3: getMethod

/**
 * Gets the HTTP method indicating the operation to perform on the resource identified in the
 * client's HTTP request. This method converts GemFire's HttpMethod enumerated value from the Link
 * into a corresponding Spring HttpMethod enumerated value.
 * <p/>
 * 
 * @return a Spring HttpMethod enumerated value indicating the operation to perform on the
 *         resource identified in the client's HTTP request.
 * @see org.apache.geode.management.internal.web.http.HttpMethod
 * @see org.apache.geode.management.internal.web.domain.Link#getMethod()
 * @see org.springframework.http.HttpMethod
 * @see org.springframework.http.HttpRequest#getMethod()
 */
@Override
public HttpMethod getMethod() {
  switch (getLink().getMethod()) {
    case DELETE:
      return HttpMethod.DELETE;
    case HEAD:
      return HttpMethod.HEAD;
    case OPTIONS:
      return HttpMethod.OPTIONS;
    case POST:
      return HttpMethod.POST;
    case PUT:
      return HttpMethod.PUT;
    case TRACE:
      return HttpMethod.TRACE;
    case GET:
    default:
      return HttpMethod.GET;
  }
}
 
開發者ID:ampool,項目名稱:monarch,代碼行數:33,代碼來源:ClientHttpRequest.java

示例4: testNormal

@Test
public void testNormal() throws IOException {
  ServiceRegistry serviceRegistry = ServiceRegistryFactory.createLocal();
  serviceRegistry.init();
  RegistryUtils.setServiceRegistry(serviceRegistry);

  UnitTestMeta meta = new UnitTestMeta();

  CseContext.getInstance()
      .getSchemaListenerManager()
      .setSchemaListenerList(Arrays.asList(new RestEngineSchemaListener()));

  SchemaMeta schemaMeta = meta.getOrCreateSchemaMeta(SpringmvcImpl.class);
  CseContext.getInstance().getSchemaListenerManager().notifySchemaListener(schemaMeta);

  Holder<Invocation> holder = new Holder<>();
  CseClientHttpRequest client =
      new CseClientHttpRequest(URI.create("cse://app:test/" + SpringmvcImpl.class.getSimpleName() + "/bytes"),
          HttpMethod.POST) {

        /**
         * {@inheritDoc}
         */
        @Override
        protected Response doInvoke(Invocation invocation) {
          holder.value = invocation;
          return Response.ok("result");
        }
      };
  byte[] body = "abc".getBytes();
  client.setRequestBody(body);

  client.execute();

  Assert.assertArrayEquals(body, holder.value.getSwaggerArgument(0));
}
 
開發者ID:apache,項目名稱:incubator-servicecomb-java-chassis,代碼行數:36,代碼來源:TestCseClientHttpRequest.java

示例5: httpMethod

protected HttpMethod httpMethod() {
    return HttpMethod.POST;
}
 
開發者ID:Huawei,項目名稱:Server_Management_Common_eSightApi,代碼行數:3,代碼來源:DeleteFirmwareApi.java

示例6: httpMethod

protected HttpMethod httpMethod() {
  return HttpMethod.POST;
}
 
開發者ID:Huawei,項目名稱:Server_Management_Common_eSightApi,代碼行數:3,代碼來源:PostFirmwareUploadApi.java

示例7: facebookPagePostAsAdmin

/**
 * Create a request for a Post as the page admin (not as the user)
 * @param linkToPost the link to post
 */
public void facebookPagePostAsAdmin(String linkToPost) {
	this.api = API_PAGE_POST_AS_ADMIN;
	this.setParameter("link", linkToPost);
	this.httpMethod = HttpMethod.POST;
}
 
開發者ID:xtianus,項目名稱:yadaframework,代碼行數:9,代碼來源:YadaFacebookRequest.java


注:本文中的org.springframework.http.HttpMethod.POST屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。