Java 类javax.ws.rs.HttpMethod 实例源码

项目:personium-core    文件:BatchRequestShutterTest.java   
/**
 * シャッターONの場合GETメソッドのみ許可されること.
 */
@Test
public void シャッターONの場合GETメソッドのみ許可されること() {
    Exception e = PersoniumCoreException.Misc.TOO_MANY_CONCURRENT_REQUESTS;

    BatchRequestShutter shutter = new BatchRequestShutter();
    assertFalse(shutter.isShuttered());

    shutter.updateStatus(e);

    // チェック
    assertFalse(shutter.accept(HttpMethod.POST));
    assertTrue(shutter.accept(HttpMethod.GET));
    assertFalse(shutter.accept(HttpMethod.PUT));
    assertFalse(shutter.accept(HttpMethod.DELETE));
}
项目:personium-core    文件:LogListTest.java   
/**
 * アーカイブログファイル一覧取得_Depthヘッダの指定がない場合に400が返却されること.
 */
@Test
public final void アーカイブログファイル一覧取得_Depthヘッダの指定がない場合に400が返却されること() {

    String body = "<?xml version=\"1.0\" encoding=\"utf-8\"?>"
            + "<D:propfind xmlns:D=\"DAV:\"><D:allprop/></D:propfind>";

    Http.request("cell/log-propfind-with-body-no-depth.txt")
            .with("METHOD", io.personium.common.utils.PersoniumCoreUtils.HttpMethod.PROPFIND)
            .with("token", AbstractCase.MASTER_TOKEN_NAME)
            .with("cellPath", Setup.TEST_CELL_EVENTLOG)
            .with("collection", ARCHIVE_COLLECTION)
            .with("body", body)
            .returns()
            .statusCode(HttpStatus.SC_BAD_REQUEST);
}
项目:dotwebstack-framework    文件:ErrorModuleTest.java   
@Test
public void initialize_RegistersErrorResource_WhenCalled() {
  // Act
  errorModule.initialize(httpConfigurationMock);

  // Assert
  verify(httpConfigurationMock).registerResources(resourceCaptor.capture());
  assertThat(resourceCaptor.getAllValues(), hasSize(1));

  Resource resource = resourceCaptor.getValue();
  assertThat(resource.getPath(), equalTo("/{domain}/__errors/{statusCode:\\d{3}}"));
  assertThat(resource.getResourceMethods(), hasSize(1));

  ResourceMethod method = resource.getResourceMethods().get(0);
  assertThat(method.getHttpMethod(), CoreMatchers.equalTo(HttpMethod.GET));
  assertThat(method.getProducedTypes(), contains(MediaType.TEXT_PLAIN_TYPE));

  Object handler = resource.getHandlerInstances().iterator().next();
  assertThat(handler, instanceOf(ServletErrorHandler.class));
}
项目:personium-core    文件:RoleUtils.java   
/**
 * NP経由でRoleを作成するユーティリティ.
 * @param cellName セル名
 * @param token トークン
 * @param srcEntityName ソース側エンティティタイプ名
 * @param srcEntityKeyString ソース側エンティティキー文字列(例:"Name='xxx'")
 * @param roleName ロール名
 * @param code レスポンスコード
 * @return レスポンス
 */
@SuppressWarnings("unchecked")
public static TResponse createViaNP(
        final String cellName,
        final String token,
        final String srcEntityName,
        final String srcEntityKeyString,
        final String roleName,
        final int code) {
    JSONObject body = new JSONObject();
    body.put("Name", roleName);

    return Http.request("cell/createNPWithoutQuote.txt")
            .with("method", HttpMethod.POST)
            .with("token", "Bearer " + token)
            .with("cell", cellName)
            .with("entityType", srcEntityName)
            .with("id", srcEntityKeyString)
            .with("navPropName", "_Role")
            .with("accept", MediaType.APPLICATION_JSON)
            .with("contentType", MediaType.APPLICATION_JSON)
            .with("body", body.toJSONString())
            .returns()
            .statusCode(code);
}
项目:dotwebstack-framework    文件:LdRedirectionRequestMapper.java   
private void mapRedirection(Redirection redirection, HttpConfiguration httpConfiguration) {
  String basePath = redirection.getStage().getFullPath();

  String urlPattern = redirection.getUrlPattern().replaceAll("^\\^", "");
  String absolutePathRegex = String.format("%s{any: %s}", basePath, urlPattern);

  Resource.Builder resourceBuilder = Resource.builder().path(absolutePathRegex);
  resourceBuilder.addMethod(HttpMethod.GET).handledBy(
      new RedirectionRequestHandler(redirection)).nameBindings(ExpandFormatParameter.class);

  if (!httpConfiguration.resourceAlreadyRegistered(absolutePathRegex)) {
    httpConfiguration.registerResources(resourceBuilder.build());
    LOG.debug("Mapped GET redirection for request path {}", absolutePathRegex);
  } else {
    LOG.error("Resource <%s> is not registered", absolutePathRegex);
  }
}
项目:dotwebstack-framework    文件:LdRepresentationRequestMapperTest.java   
@Test
public void loadRepresentations_MapRepresentation_WithValidData() {
  // Arrange
  when(supportedMediaTypesScanner.getMediaTypes(any())).thenReturn(
      new MediaType[] {MediaType.valueOf("text/turtle")});

  // Act
  ldRepresentationRequestMapper.loadRepresentations(httpConfiguration);

  // Assert
  Resource resource = (Resource) httpConfiguration.getResources().toArray()[0];
  final ResourceMethod method = resource.getResourceMethods().get(0);
  assertThat(httpConfiguration.getResources(), hasSize(1));
  assertThat(resource.getPath(), equalTo("/" + DBEERPEDIA.ORG_HOST
      + DBEERPEDIA.BASE_PATH.getLabel() + DBEERPEDIA.URL_PATTERN_VALUE));
  assertThat(resource.getResourceMethods(), hasSize(1));
  assertThat(method.getHttpMethod(), equalTo(HttpMethod.GET));
}
项目:personium-core    文件:LogListTest.java   
/**
 * アーカイブログファイル一覧取得にDepth0を指定した場合に1階層分だけ返却されること.
 */
@Test
public final void アーカイブログファイル一覧取得にDepth0を指定した場合に1階層分だけ返却されること() {

    String body = "<?xml version=\"1.0\" encoding=\"utf-8\"?>"
            + "<D:propfind xmlns:D=\"DAV:\"><D:allprop/></D:propfind>";

    TResponse tresponse = Http.request("cell/log-propfind-with-body.txt")
            .with("METHOD", io.personium.common.utils.PersoniumCoreUtils.HttpMethod.PROPFIND)
            .with("token", AbstractCase.MASTER_TOKEN_NAME)
            .with("cellPath", Setup.TEST_CELL_EVENTLOG)
            .with("collection", ARCHIVE_COLLECTION)
            .with("depth", "0")
            .with("body", body)
            .returns()
            .debug()
            .statusCode(HttpStatus.SC_MULTI_STATUS);

    // BodyXMLからの要素取得
    checkLogListResponse(tresponse, Setup.TEST_CELL_EVENTLOG, 0);
}
项目:personium-core    文件:LogListTest.java   
/**
 * アーカイブログファイル一覧取得_ボディ不正な形式のXMLを指定したPROPFINDで400が返却されること.
 */
@Test
public final void アーカイブログファイル一覧取得_ボディ不正な形式のXMLを指定したPROPFINDで400が返却されること() {
    // 最初の要素のとじカッコがないXMLをボディに指定する
    String body = "<?xml version=\"1.0\" encoding=\"utf-8\"?"
            + "<D:propfind xmlns:D=\"DAV:\"><D:allprop/></D:propfind>";

    Http.request("cell/log-propfind-with-body.txt")
            .with("METHOD", io.personium.common.utils.PersoniumCoreUtils.HttpMethod.PROPFIND)
            .with("token", AbstractCase.MASTER_TOKEN_NAME)
            .with("cellPath", Setup.TEST_CELL_EVENTLOG)
            .with("collection", ARCHIVE_COLLECTION)
            .with("depth", "0")
            .with("body", body)
            .returns()
            .statusCode(HttpStatus.SC_BAD_REQUEST);
}
项目:personium-core    文件:EventArchiveLogGetTest.java   
/**
 * archiveされた過去ログを取得で不正なメソッドを指定した場合405が返却されること.
 */
@Test
public final void archiveされた過去ログを取得で不正なメソッドを指定した場合405が返却されること() {
    final String token = AbstractCase.MASTER_TOKEN_NAME;
    final String cell = Setup.TEST_CELL_EVENTLOG;

    String archiveLogName = String.format(DEFAULT_LOG_FORMAT, 1);
    TResponse response = Http.request("cell/log-get.txt")
            .with("METHOD", HttpMethod.POST)
            .with("token", token)
            .with("cellPath", cell)
            .with("collection", ARCHIVE_COLLECTION)
            .with("fileName", archiveLogName)
            .with("ifNoneMatch", "*")
            .returns();
    response.statusCode(HttpStatus.SC_METHOD_NOT_ALLOWED);
}
项目:personium-core    文件:AbstractCase.java   
/**
 * DcRequestオブジェクトを使用してリクエスト実行.
 * @param req リクエストパラメータ
 * @return res
 */
public static PersoniumResponse request(PersoniumRequest req) {
    PersoniumRestAdapter rest = new PersoniumRestAdapter();
    PersoniumResponse res = null;
    String method = req.getMethod();
    try {
        // リクエスト
        if (method.equals(HttpMethod.GET)) {
            res = rest.getAcceptEncodingGzip(req.getUrl(), req.getHeaders());
        } else if (method.equals(HttpMethod.PUT)) {
            res = rest.put(req.getUrl(), req.getBody(), req.getHeaders());
        } else if (method.equals(HttpMethod.POST)) {
            res = rest.post(req.getUrl(), req.getBody(), req.getHeaders());
        } else if (method.equals(HttpMethod.DELETE)) {
            res = rest.del(req.getUrl(), req.getHeaders());
        } else {
            res = rest.request(method, req.getUrl(), req.getBody(), req.getHeaders());
        }
    } catch (Exception e) {
        fail(e.getMessage());
    }
    return res;
}
项目:plugin-km-confluence    文件:ConfluencePluginResource.java   
/**
 * Validate the space configuration and return the corresponding details.
 */
protected CurlRequest[] validateSpaceInternal(final Map<String, String> parameters, final String... partialRequests) {
    final String url = StringUtils.removeEnd(parameters.get(PARAMETER_URL), "/");
    final String space = ObjectUtils.defaultIfNull(parameters.get(PARAMETER_SPACE), "0");
    final CurlRequest[] result = new CurlRequest[partialRequests.length];
    for (int i = 0; i < partialRequests.length; i++) {
        result[i] = new CurlRequest(HttpMethod.GET, url + partialRequests[i] + space, null);
        result[i].setSaveResponse(true);
    }

    // Prepare the sequence of HTTP requests to Confluence
    final ConfluenceCurlProcessor processor = new ConfluenceCurlProcessor();
    authenticate(parameters, processor);

    // Execute the requests
    processor.process(result);

    // Get the space if it exists
    if (result[0].getResponse() == null) {
        // Invalid couple PKEY and id
        throw new ValidationJsonException(PARAMETER_SPACE, "confluence-space", parameters.get(PARAMETER_SPACE));
    }
    return result;
}
项目:personium-core    文件:EventTest.java   
/**
 * イベント受付時のrequestKeyヘッダに不正文字を含めた値を指定しPOSTした場合400が返却されること.
 */
@Test
public final void イベント受付時のrequestKeyヘッダに不正文字を含めた値を指定しPOSTした場合400が返却されること() {

    TResponse response =
            Http.request("cell/cell-event.txt")
                    .with("METHOD", HttpMethod.POST)
                    .with("token", AbstractCase.MASTER_TOKEN_NAME)
                    .with("cellPath", Setup.TEST_CELL1)
                    .with("requestKey", "abc#123")
                    .with("json", "")
                    .returns();
    response.checkErrorResponse("PR400-EV-0002",
            PersoniumCoreException.Event.X_PERSONIUM_REQUESTKEY_INVALID.getMessage());
    response.statusCode(HttpStatus.SC_BAD_REQUEST);
}
项目:personium-core    文件:DavCollectionResource.java   
/**
 * OPTIONSメソッド.
 * @return JAX-RS Response
 */
@OPTIONS
public Response options() {
    // アクセス制御
    this.davRsCmp.checkAccessContext(this.davRsCmp.getAccessContext(), BoxPrivilege.READ);

    return PersoniumCoreUtils.responseBuilderForOptions(
            HttpMethod.GET,
            HttpMethod.PUT,
            HttpMethod.DELETE,
            io.personium.common.utils.PersoniumCoreUtils.HttpMethod.MKCOL,
            io.personium.common.utils.PersoniumCoreUtils.HttpMethod.MOVE,
            io.personium.common.utils.PersoniumCoreUtils.HttpMethod.PROPFIND,
            io.personium.common.utils.PersoniumCoreUtils.HttpMethod.PROPPATCH,
            io.personium.common.utils.PersoniumCoreUtils.HttpMethod.ACL
            ).build();
}
项目:personium-core    文件:AccountUtils.java   
/**
 * NP経由でAccountを作成するユーティリティ.
 * @param cellName Cell名
 * @param token 認証トークン(Bearerなし)
 * @param srcEntityName NP経由元のエンティティ名
 * @param srcEntityKeyString NP経由元のID
 * @param body リクエストボディ
 * @param code 期待するレスポンスコード
 * @return レスポンス
 */
public static TResponse createViaNPNonCredential(
        final String cellName,
        final String token,
        final String srcEntityName,
        final String srcEntityKeyString,
        final String body,
        final int code) {
    return Http.request("cell/createNP.txt")
            .with("method", HttpMethod.POST)
            .with("token", token)
            .with("cell", cellName)
            .with("entityType", srcEntityName)
            .with("id", srcEntityKeyString)
            .with("navPropName", "_Account")
            .with("accept", MediaType.APPLICATION_JSON)
            .with("contentType", MediaType.APPLICATION_JSON)
            .with("body", body)
            .returns()
            .statusCode(code);
}
项目:personium-core    文件:PersoniumCoreContainerFilter.java   
/**
 * 認証なしOPTIONメソッドのレスポンスを返却する.
 * @param request フィルタ前リクエスト
 */
private void responseOptionsMethod(ContainerRequest request) {
    String authValue = request.getHeaderValue(org.apache.http.HttpHeaders.AUTHORIZATION);
    String methodName = request.getMethod();
    if (authValue == null && HttpMethod.OPTIONS.equals(methodName)) {
        Response res = PersoniumCoreUtils.responseBuilderForOptions(
                HttpMethod.GET,
                HttpMethod.POST,
                HttpMethod.PUT,
                HttpMethod.DELETE,
                HttpMethod.HEAD,
                io.personium.common.utils.PersoniumCoreUtils.HttpMethod.MERGE,
                io.personium.common.utils.PersoniumCoreUtils.HttpMethod.MKCOL,
                io.personium.common.utils.PersoniumCoreUtils.HttpMethod.MOVE,
                io.personium.common.utils.PersoniumCoreUtils.HttpMethod.PROPFIND,
                io.personium.common.utils.PersoniumCoreUtils.HttpMethod.PROPPATCH,
                io.personium.common.utils.PersoniumCoreUtils.HttpMethod.ACL
                ).build();

        // 例外を発行することでServletへ制御を渡さない
        throw new WebApplicationException(res);
    }
}
项目:personium-core    文件:RoleUtils.java   
/**
 * ロールの$links一覧を取得するユーティリティ.
 * @param cellName セル名
 * @param sourceEntityType ソース側エンティティタイプ名
 * @param sourceEntityKeyString ソース側エンティティキー文字列(例:"Name='xxx'")
 * @param authorization Authorizationヘッダの値(auth-schemaを含む文字列)
 * @param code 期待するレスポンスコード
 * @return レスポンス
 */
public static TResponse listLinkWithAuthSchema(
        final String cellName,
        final String authorization,
        final String sourceEntityType,
        final String sourceEntityKeyString,
        final int code) {

    String key = sourceEntityKeyString;
    if (key != null && !key.contains("'")) {
        key = "'" + sourceEntityKeyString + "'";
    }
    return Http.request("links-request-anyAuthSchema.txt")
            .with("method", HttpMethod.GET)
            .with("authorization", authorization)
            .with("cellPath", cellName)
            .with("entitySet", sourceEntityType)
            .with("key", key)
            .with("navProp", "_Role")
            .returns()
            .statusCode(code);
}
项目:personium-core    文件:LogListTest.java   
/**
 * アーカイブログファイル一覧取得_ボディに不正なプロパティが指定さた場合400が返却されること.
 */
@Test
public final void アーカイブログファイル一覧取得_ボディに不正なプロパティが指定さた場合400が返却されること() {

    String body = "<?xml version=\"1.0\" encoding=\"utf-8\"?>"
            + "<D:propfind xmlns:D=\"DAV:\"><D:hoge/></D:propfind>";

    Http.request("cell/log-propfind-with-body.txt")
            .with("METHOD", io.personium.common.utils.PersoniumCoreUtils.HttpMethod.PROPFIND)
            .with("token", AbstractCase.MASTER_TOKEN_NAME)
            .with("cellPath", Setup.TEST_CELL_EVENTLOG)
            .with("collection", ARCHIVE_COLLECTION)
            .with("depth", "1")
            .with("body", body)
            .returns()
            .debug()
            .statusCode(HttpStatus.SC_BAD_REQUEST);
}
项目:personium-core    文件:BoxUtils.java   
/**
 * BOX NP経由登録ユーティリティ.
 * @param token トークン
 * @param cellName Cell名
 * @param sourceEntityType ソース側EntityType名
 * @param sourceEntityKeyString ソース側キー(例:"Name='test'")
 * @param body リクエストボディ
 * @param code レスポンスコード
 * @return レスポンス
 */
public static TResponse createViaNP(
        final String token,
        final String cellName,
        final String sourceEntityType,
        final String sourceEntityKeyString,
        final String body,
        final int code) {
    // Box作成
    return Http.request("cell/createNPWithoutQuote.txt")
            .with("method", HttpMethod.POST)
            .with("token", "Bearer " + token)
            .with("cell", cellName)
            .with("entityType", sourceEntityType)
            .with("id", sourceEntityKeyString)
            .with("navPropName", "_Box")
            .with("accept", MediaType.APPLICATION_JSON)
            .with("contentType", MediaType.APPLICATION_JSON)
            .with("body", body)
            .returns()
            .statusCode(code);
}
项目:incubator-servicecomb-java-chassis    文件:JaxrsSwaggerGeneratorContext.java   
@Override
public boolean canProcess(Method method) {
  for (Annotation annotation : method.getAnnotations()) {
    HttpMethod httpMethod = annotation.annotationType().getAnnotation(HttpMethod.class);
    if (httpMethod != null) {
      return true;
    }
  }

  return false;
}
项目:incubator-servicecomb-java-chassis    文件:HttpMethodAnnotationProcessor.java   
@Override
public void process(Object annotation, OperationGenerator operationGenerator) {
  Annotation httpMethodAnnotation = (Annotation) annotation;
  HttpMethod httpMethod = httpMethodAnnotation.annotationType().getAnnotation(HttpMethod.class);

  operationGenerator.setHttpMethod(httpMethod.value());
}
项目:personium-core    文件:PersoniumReadDeleteModeManagerTest.java   
/**
 * ReadDeleteOnlyモードではない状態でPROPPATCHメソッドが実行された場合はPersoniumCoreExceptionが発生しないこと.
 * @throws Exception .
 */
@Test
public void ReadDeleteOnlyモードではない状態でPROPPATCHメソッドが実行された場合はPersoniumCoreExceptionが発生しないこと() throws Exception {
    PowerMockito.spy(ReadDeleteModeLockManager.class);
    PowerMockito.when(ReadDeleteModeLockManager.class, "isReadDeleteOnlyMode").thenReturn(false);
    List<PathSegment> pathSegment = getPathSegmentList(new String[] {"cell", "box", "odata", "entity" });
    try {
        PersoniumReadDeleteModeManager.checkReadDeleteOnlyMode(
                PersoniumCoreUtils.HttpMethod.PROPPATCH, pathSegment);
    } catch (PersoniumCoreException e) {
        fail(e.getMessage());
    }
}
项目:personium-core    文件:CellUtils.java   
/**
 * eventのPOSTを行うユーティリティ.
 * @param token 認証トークン
 * @param code レスポンスコード
 * @param cellName セル名
 * @param jsonBody リクエストボディ
 */
public static void event(String token, int code, String cellName, String jsonBody) {
    Http.request("cell/cell-event.txt")
            .with("METHOD", HttpMethod.POST)
            .with("token", token)
            .with("cellPath", cellName)
            .with("requestKey", "")
            .with("json", jsonBody)
            .returns()
            .statusCode(code);
}
项目:personium-core    文件:LogTest.java   
/**
 * デフォルトログ以外のファイルに対するGETで404が返却されること.
 */
@Test
public final void デフォルトログ以外のファイルに対するGETで404が返却されること() {

    Http.request("cell/log-get.txt")
            .with("METHOD", HttpMethod.GET)
            .with("token", AbstractCase.MASTER_TOKEN_NAME)
            .with("cellPath", Setup.TEST_CELL1)
            .with("collection", CURRENT_COLLECTION)
            .with("fileName", "InvalidFileName.log")
            .with("ifNoneMatch", "*")
            .returns()
            .debug()
            .statusCode(HttpStatus.SC_NOT_FOUND);
}
项目:microprofile-opentracing    文件:OpentracingClientTests.java   
/**
 * Test class and endpoint annotated with an operationName.
 * @throws InterruptedException Error executing web service.
 */
@Test
@RunAsClient
private void testClassAndMethodOperationName() throws InterruptedException {
    Response response = executeRemoteWebServiceRaw(TestServerWebServicesWithOperationName.REST_TEST_SERVICE_PATH_WITH_OP_NAME,
            TestServerWebServicesWithOperationName.REST_OPERATION_CLASS_AND_METHOD_OP_NAME, Status.OK);
    response.close();

    TestSpanTree spans = executeRemoteWebServiceTracerTree();

    TestSpanTree expectedTree = new TestSpanTree(
        new TreeNode<>(
            new TestSpan(
                TestServerWebServicesWithOperationName.ENDPOINT_OPERATION_NAME,
                getExpectedSpanTags(
                    Tags.SPAN_KIND_SERVER,
                    HttpMethod.GET,
                    TestServerWebServicesWithOperationName.REST_TEST_SERVICE_PATH_WITH_OP_NAME,
                    TestServerWebServicesWithOperationName.REST_OPERATION_CLASS_AND_METHOD_OP_NAME,
                    null,
                    Status.OK.getStatusCode()
                ),
                Collections.emptyList()
            )
        )
    );
    assertEqualTrees(spans, expectedTree);
}
项目:personium-core    文件:PersoniumReadDeleteModeManagerTest.java   
/**
 * ReadDeleteOnlyモードではない状態でACLメソッドが実行された場合はPersoniumCoreExceptionが発生しないこと.
 * @throws Exception .
 */
@Test
public void ReadDeleteOnlyモードではない状態でACLメソッドが実行された場合はPersoniumCoreExceptionが発生しないこと() throws Exception {
    PowerMockito.spy(ReadDeleteModeLockManager.class);
    PowerMockito.when(ReadDeleteModeLockManager.class, "isReadDeleteOnlyMode").thenReturn(false);
    List<PathSegment> pathSegment = getPathSegmentList(new String[] {"cell", "box", "odata", "entity" });
    try {
        PersoniumReadDeleteModeManager.checkReadDeleteOnlyMode(PersoniumCoreUtils.HttpMethod.ACL,
                pathSegment);
    } catch (PersoniumCoreException e) {
        fail(e.getMessage());
    }
}
项目:microprofile-opentracing    文件:OpentracingClientTests.java   
/**
 * Test annotation exception web service.
 */
@Test
@RunAsClient
private void testAnnotationException() throws InterruptedException {
    Response response = executeRemoteWebServiceRaw(TestServerWebServices.REST_TEST_SERVICE_PATH,
            TestServerWebServices.REST_ANNOTATION_EXCEPTION, Status.OK);
    response.close();

    TestSpanTree spans = executeRemoteWebServiceTracerTree();

    TestSpanTree expectedTree = new TestSpanTree(
        new TreeNode<>(
            new TestSpan(
                getOperationName(
                    Tags.SPAN_KIND_SERVER,
                    HttpMethod.GET,
                    TestServerWebServices.class,
                    TestServerWebServices.REST_ANNOTATION_EXCEPTION
                ),
                getExpectedSpanTags(
                    Tags.SPAN_KIND_SERVER,
                    HttpMethod.GET,
                    TestServerWebServices.REST_TEST_SERVICE_PATH,
                    TestServerWebServices.REST_ANNOTATION_EXCEPTION,
                    null,
                    Status.OK.getStatusCode()
                ),
                Collections.emptyList()
            ),
            new TreeNode<>(
                new TestSpan(
                    TestAnnotatedClass.class.getName() + ".annotatedClassMethodImplicitlyTracedWithException",
                    Collections.emptyMap(),
                    Collections.emptyList()
                )
            )
        )
    );
    assertEqualTrees(spans, expectedTree);
}
项目:personium-core    文件:LogTest.java   
/**
 * archiveコレクションを指定したGETで404が返却されること.
 */
@Test
public final void archiveコレクションを指定したGETで404が返却されること() {

    Http.request("cell/log-get.txt")
            .with("METHOD", HttpMethod.GET)
            .with("token", AbstractCase.MASTER_TOKEN_NAME)
            .with("cellPath", Setup.TEST_CELL1)
            .with("collection", "archive")
            .with("fileName", DEFAULT_LOG)
            .with("ifNoneMatch", "*")
            .returns()
            .debug()
            .statusCode(HttpStatus.SC_NOT_FOUND);
}
项目:oscm    文件:RedirectNavigationHandler.java   
/**
 * @param context
 *            - FacesContext
 * @param outcome
 *            - navigate to
 * @return - true if redirection is needed, false otherwise
 */
private boolean isRedirectNeeded(FacesContext context, String outcome) {
    HttpServletRequest request = (HttpServletRequest) context
            .getExternalContext().getRequest();

    return notNull(request)
            && notNull(request.getMethod())
            && !outcome.endsWith(FACES_REDIRECT)
            && HttpMethod.POST.equals(request.getMethod());
}
项目:personium-core    文件:PersoniumReadDeleteModeManagerTest.java   
/**
 * ReadDeleteOnlyモード時にPROPFINDメソッドが実行された場合はPersoniumCoreExceptionが発生しないこと.
 * @throws Exception .
 */
@Test
public void ReadDeleteOnlyモード時にPROPFINDメソッドが実行された場合はPersoniumCoreExceptionが発生しないこと() throws Exception {
    PowerMockito.spy(ReadDeleteModeLockManager.class);
    PowerMockito.when(ReadDeleteModeLockManager.class, "isReadDeleteOnlyMode").thenReturn(true);
    List<PathSegment> pathSegment = getPathSegmentList(new String[] {"cell", "box", "odata", "entity" });
    try {
        PersoniumReadDeleteModeManager.checkReadDeleteOnlyMode(
                PersoniumCoreUtils.HttpMethod.PROPFIND, pathSegment);
    } catch (PersoniumCoreException e) {
        fail(e.getMessage());
    }
}
项目:dotwebstack-framework    文件:ErrorModule.java   
@Override
public void initialize(@NonNull HttpConfiguration httpConfiguration) {
  Resource.Builder resourceBuilder =
      Resource.builder().path(String.format("/{domain}/%s/{%s:\\d{3}}",
          SERVLET_ERROR_PATH_PREFIX, SERVLET_ERROR_STATUS_CODE_PARAMETER));
  resourceBuilder.addMethod(HttpMethod.GET).handledBy(new ServletErrorHandler()).produces(
      MediaType.TEXT_PLAIN_TYPE);
  httpConfiguration.registerResources(resourceBuilder.build());
}
项目:XXXX    文件:JAXRSContract.java   
@Override
protected void processAnnotationOnMethod(MethodMetadata data, Annotation methodAnnotation,
                                         Method method) {
  Class<? extends Annotation> annotationType = methodAnnotation.annotationType();
  HttpMethod http = annotationType.getAnnotation(HttpMethod.class);
  if (http != null) {
    checkState(data.template().method() == null,
               "Method %s contains multiple HTTP methods. Found: %s and %s", method.getName(),
               data.template().method(), http.value());
    data.template().method(http.value());
  } else if (annotationType == Path.class) {
    String pathValue = emptyToNull(Path.class.cast(methodAnnotation).value());
    checkState(pathValue != null, "Path.value() was empty on method %s", method.getName());
    String methodAnnotationValue = Path.class.cast(methodAnnotation).value();
    if (!methodAnnotationValue.startsWith("/") && !data.template().url().endsWith("/")) {
      methodAnnotationValue = "/" + methodAnnotationValue;
    }
    // jax-rs allows whitespace around the param name, as well as an optional regex. The contract should
    // strip these out appropriately.
    methodAnnotationValue = methodAnnotationValue.replaceAll("\\{\\s*(.+?)\\s*(:.+?)?\\}", "\\{$1\\}");
    data.template().append(methodAnnotationValue);
  } else if (annotationType == Produces.class) {
    handleProducesAnnotation(data, (Produces) methodAnnotation, "method " + method.getName());
  } else if (annotationType == Consumes.class) {
    handleConsumesAnnotation(data, (Consumes) methodAnnotation, "method " + method.getName());
  }
}
项目:minijax    文件:MinijaxApplication.java   
private void registerResourceMethods(final Class<?> c) {
    for (final Method method : c.getDeclaredMethods()) {
        for (final Annotation annotation : method.getAnnotations()) {
            final HttpMethod httpMethod = annotation.annotationType().getAnnotation(HttpMethod.class);
            if (httpMethod != null) {
                resourceMethods.add(new MinijaxResourceMethod(httpMethod.value(), method, getParamProviders(method)));
            }
        }
    }
}
项目:plugin-vm-vcloud    文件:VCloudPluginResource.java   
/**
 * Cache the API token.
 */
protected String authenticate(final String url, final String authentication, final VCloudCurlProcessor processor) {
    return curlCacheToken.getTokenCache(VCloudPluginResource.class, url + "##" + authentication, k -> {

        // Authentication request
        final CurlRequest request = new CurlRequest(HttpMethod.POST, url, null, VCloudCurlProcessor.LOGIN_CALLBACK,
                "Authorization:Basic " + authentication);
        // TODO Use request.setTimeout(...) with plugin-api 1.1.8+
        processor.process(Collections.singletonList(request));
        return processor.token;
    }, retries, () -> new ValidationJsonException(PARAMETER_API, "vcloud-login"));
}
项目:redirector    文件:PermissionsHelperTest.java   
@Test
public void granularWritePermission_IsGranted_When_noOrdinaryPermissionsArePresent () {
    currentPermissions.add("RESTOnly-allow-write-namespacedLists-ns1");

    assertTrue(PermissionHelper.isAuthorized(ROOT_PATH + RedirectorConstants.DELIMETER +
            DATA_ENDPOINT + RedirectorConstants.DELIMETER + "namespacedLists/ns1", HttpMethod.POST, currentPermissions));
}
项目:personium-core    文件:EventTest.java   
/**
 * イベント受付に対するPOSTで200が返却されること.
 */
@Test
public final void イベント受付に対するPOSTで200が返却されること() {
    JSONObject body = createEventBody();

    Http.request("cell/cell-event.txt")
            .with("METHOD", HttpMethod.POST)
            .with("token", AbstractCase.MASTER_TOKEN_NAME)
            .with("cellPath", Setup.TEST_CELL1)
            .with("requestKey", "testRequestKey")
            .with("json", body.toJSONString())
            .returns()
            .statusCode(HttpStatus.SC_OK);
}
项目:redirector    文件:PermissionsHelperTest.java   
@Test
public void granularWritePermission_IsGranted_When_ordinaryPermissionsArePresent () {
    currentPermissions.add("RESTOnly-allow-write-namespacedLists-ns1");
    currentPermissions.add("RESTOnly-write-namespacedLists");

    assertTrue(PermissionHelper.isAuthorized(ROOT_PATH + RedirectorConstants.DELIMETER +
            DATA_ENDPOINT + RedirectorConstants.DELIMETER + "namespacedLists/ns1", HttpMethod.POST, currentPermissions));
}
项目:redirector    文件:PermissionsHelperTest.java   
@Test
public void granularWritePermission_IsRejected_When_ordinaryPermissionsArePresent () {
    currentPermissions.add("RESTOnly-deny-write-namespacedLists-ns1");
    currentPermissions.add("RESTOnly-write-namespacedLists");

    assertFalse(PermissionHelper.isAuthorized(ROOT_PATH + RedirectorConstants.DELIMETER +
            DATA_ENDPOINT + RedirectorConstants.DELIMETER + "namespacedLists/ns1", HttpMethod.POST, currentPermissions));
}
项目:personium-core    文件:ODataLinksResource.java   
/**
 * OPTIONSメソッド.
 * @return JAX-RS Response
 */
@OPTIONS
public Response options() {

    // アクセス制御
    this.odataResource.checkAccessContext(this.accessContext,
            this.odataResource.getNecessaryOptionsPrivilege());

    return PersoniumCoreUtils.responseBuilderForOptions(
            HttpMethod.GET,
            HttpMethod.DELETE,
            HttpMethod.PUT,
            HttpMethod.POST
            ).build();
}
项目:redirector    文件:PermissionsHelperTest.java   
@Test
public void granularReadPermission_IsGranted_When_noOrdinaryPermissionsArePresent () {
    currentPermissions.add("RESTOnly-allow-read-namespacedLists-ns1");

    assertTrue(PermissionHelper.isAuthorized(ROOT_PATH + RedirectorConstants.DELIMETER +
            DATA_ENDPOINT + RedirectorConstants.DELIMETER + "namespacedLists/ns1", HttpMethod.GET, currentPermissions));
}
项目:redirector    文件:PermissionsHelperTest.java   
@Test
public void granularReadPermission_IsRejected_When_noOrdinaryPermissionsArePresent () {
    currentPermissions.add("RESTOnly-deny-read-namespacedLists-ns1");

    assertFalse(PermissionHelper.isAuthorized(ROOT_PATH + RedirectorConstants.DELIMETER +
            DATA_ENDPOINT + RedirectorConstants.DELIMETER + "namespacedLists/ns1", HttpMethod.GET, currentPermissions));
}