org.mockserver.model.HttpRequest.getPath()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(9.2k)|赞(0)|评价(0)|浏览(81)

本文整理了Java中org.mockserver.model.HttpRequest.getPath()方法的一些代码示例,展示了HttpRequest.getPath()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。HttpRequest.getPath()方法的具体详情如下:
包路径:org.mockserver.model.HttpRequest
类名称:HttpRequest
方法名:getPath

HttpRequest.getPath介绍

暂无

代码示例

代码示例来源:origin: jamesdbloom/mockserver

@Override
  public HttpResponse handle(HttpRequest httpRequest) {
    if (httpRequest.getPath().getValue().endsWith("/callback")) {
      return httpResponse;
    } else {
      return notFoundResponse();
    }
  }
}

代码示例来源:origin: jamesdbloom/mockserver

@Override
  public void run() {
    KeyAndCertificateFactory.addSubjectAlternativeName(request.getPath().getValue());
  }
});

代码示例来源:origin: jamesdbloom/mockserver

if (request != null) {
  boolean methodMatches = Strings.isNullOrEmpty(request.getMethod().getValue()) || matches(context, methodMatcher, request.getMethod());
  boolean pathMatches = Strings.isNullOrEmpty(request.getPath().getValue()) || matches(context, pathMatcher, request.getPath());
  boolean queryStringParametersMatches = matches(context, queryStringParameterMatcher, request.getQueryStringParameters());
  boolean bodyMatches = bodyMatches(context, request);

代码示例来源:origin: jamesdbloom/mockserver

public void renderDashboard(final ChannelHandlerContext ctx, final HttpRequest request) throws Exception {
  HttpResponse response = notFoundResponse();
  if (request.getMethod().getValue().equals("GET")) {
    String path = StringUtils.substringAfter(request.getPath().getValue(), PATH_PREFIX + "/dashboard");
    if (path.isEmpty() || path.equals("/")) {
      path = "/index.html";

代码示例来源:origin: jamesdbloom/mockserver

jgen.writeObjectField("method", httpRequest.getMethod());
if (httpRequest.getPath() != null && !Strings.isNullOrEmpty(httpRequest.getPath().getValue())) {
  jgen.writeObjectField("path", httpRequest.getPath());

代码示例来源:origin: jamesdbloom/mockserver

output.append(".withMethod(\"").append(request.getMethod().getValue()).append("\")");
if (!Strings.isNullOrEmpty(request.getPath().getValue())) {
  appendNewLineAndIndent((numberOfSpacesToIndent + 1) * INDENT_SIZE, output);
  output.append(".withPath(\"").append(request.getPath().getValue()).append("\")");

代码示例来源:origin: jamesdbloom/mockserver

boolean isSsl = httpRequest.isSecure() != null && httpRequest.isSecure();
int port = (isSsl ? getServerSecurePort() : getServerPort());
httpRequest.withPath(addContextToPath(httpRequest.getPath().getValue()));
httpRequest.withHeader(HOST.toString(), "localhost:" + port);
boolean isDebug = java.lang.management.ManagementFactory.getRuntimeMXBean().getInputArguments().toString().indexOf("-agentlib:jdwp") > 0;

代码示例来源:origin: jamesdbloom/mockserver

HttpResponse httpResponse =
  response()
    .withStatusCode(request.getPath().equalsIgnoreCase("/not_found") ? NOT_FOUND.code() : OK.code())
    .withHeaders(request.getHeaderList());

代码示例来源:origin: jamesdbloom/mockserver

if (request.getPath().getValue().equals("/_mockserver_callback_websocket")) {

代码示例来源:origin: jamesdbloom/mockserver

public HttpRequestDTO(HttpRequest httpRequest, Boolean not) {
  super(not);
  if (httpRequest != null) {
    method = httpRequest.getMethod();
    path = httpRequest.getPath();
    headers = httpRequest.getHeaders();
    cookies = httpRequest.getCookies();
    queryStringParameters = httpRequest.getQueryStringParameters();
    body = BodyDTO.createDTO(httpRequest.getBody());
    keepAlive = httpRequest.isKeepAlive();
    secure = httpRequest.isSecure();
  }
}

代码示例来源:origin: jamesdbloom/mockserver

} else if (request.getMethod().getValue().equals("GET") && request.getPath().getValue().startsWith(PATH_PREFIX + "/dashboard")) {
    ctx.pipeline().addLast(new HttpConnectHandler(server, mockServerLogger, request.getPath().getValue(), -1));
    ctx.pipeline().remove(this);
    ctx.fireChannelRead(request);

代码示例来源:origin: jamesdbloom/mockserver

public String getURI(HttpRequest httpRequest) {
  QueryStringEncoder queryStringEncoder = new QueryStringEncoder(httpRequest.getPath().getValue());
  for (Parameter parameter : httpRequest.getQueryStringParameterList()) {
    for (NottableString value : parameter.getValues()) {
      queryStringEncoder.addParam(parameter.getName().getValue(), value.getValue());
    }
  }
  return queryStringEncoder.toString();
}

代码示例来源:origin: jamesdbloom/mockserver

public HttpRequestTemplateObject(HttpRequest httpRequest) {
  if (httpRequest != null) {
    method = httpRequest.getMethod().getValue();
    path = httpRequest.getPath().getValue();
    for (Header header : httpRequest.getHeaderList()) {
      headers.put(header.getName().getValue(), Lists.transform(header.getValues(), new Function<NottableString, String>() {
        public String apply(NottableString input) {
          return input.getValue();
        }
      }));
    }
    for (Cookie cookie : httpRequest.getCookieList()) {
      cookies.put(cookie.getName().getValue(), cookie.getValue().getValue());
    }
    for (Parameter parameter : httpRequest.getQueryStringParameterList()) {
      queryStringParameters.put(parameter.getName().getValue(), Lists.transform(parameter.getValues(), new Function<NottableString, String>() {
        public String apply(NottableString input) {
          return input.getValue();
        }
      }));
    }
    body = BodyDTO.createDTO(httpRequest.getBody());
    keepAlive = httpRequest.isKeepAlive();
    secure = httpRequest.isSecure();
  }
}

代码示例来源:origin: jamesdbloom/mockserver

@Override
public void writeResponse(HttpRequest request, HttpResponse response, boolean apiResponse) {
  if (response == null) {
    response = notFoundResponse();
  }
  if (enableCORSForAllResponses()) {
    addCORSHeaders.addCORSHeaders(request, response);
  } else if (apiResponse && enableCORSForAPI()) {
    addCORSHeaders.addCORSHeaders(request, response);
  }
  if (apiResponse) {
    response.withHeader("version", org.mockserver.Version.getVersion());
    final String path = request.getPath().getValue();
    if (!path.startsWith(PATH_PREFIX)) {
      response.withHeader("deprecated",
        "\"" + path + "\" is deprecated use \"" + PATH_PREFIX + path + "\" instead");
    }
  }
  addConnectionHeader(request, response);
  writeAndCloseSocket(ctx, request, response);
}

代码示例来源:origin: jamesdbloom/mockserver

@Override
public void writeResponse(HttpRequest request, HttpResponse response, boolean apiResponse) {
  if (response == null) {
    response = notFoundResponse();
  }
  if (enableCORSForAllResponses()) {
    addCORSHeaders.addCORSHeaders(request, response);
  } else if (apiResponse && enableCORSForAPI()) {
    addCORSHeaders.addCORSHeaders(request, response);
  }
  if (apiResponse) {
    response.withHeader("version", org.mockserver.Version.getVersion());
    final String path = request.getPath().getValue();
    if (!path.startsWith(PATH_PREFIX)) {
      response.withHeader("deprecated",
        "\"" + path + "\" is deprecated use \"" + PATH_PREFIX + path + "\" instead");
    }
  }
  addConnectionHeader(request, response);
  mockServerResponseToHttpServletResponseEncoder.mapMockServerResponseToHttpServletResponse(response, httpServletResponse);
}

代码示例来源:origin: jamesdbloom/mockserver

public HttpRequest update(HttpRequest replaceRequest) {
    if (!Strings.isNullOrEmpty(replaceRequest.getMethod().getValue())) {
      withMethod(replaceRequest.getMethod());
    }
    if (!Strings.isNullOrEmpty(replaceRequest.getPath().getValue())) {
      withPath(replaceRequest.getPath());
    }
    for (Header header : replaceRequest.getHeaderList()) {
      getHeaders().replaceEntry(header);
    }
    for (Cookie cookie : replaceRequest.getCookieList()) {
      withCookie(cookie);
    }
    for (Parameter parameter : replaceRequest.getQueryStringParameterList()) {
      getQueryStringParameters().replaceEntry(parameter);
    }
    if (replaceRequest.getBody() != null) {
      withBody(replaceRequest.getBody());
    }
    if (replaceRequest.isSecure() != null) {
      withSecure(replaceRequest.isSecure());
    }
    if (replaceRequest.isKeepAlive() != null) {
      withKeepAlive(replaceRequest.isKeepAlive());
    }
    return this;
  }
}

代码示例来源:origin: jamesdbloom/mockserver

public HttpRequestMatcher(HttpRequest httpRequest, MockServerLogger mockServerLogger) {
  this.httpRequest = httpRequest;
  this.mockServerLogger = mockServerLogger;
  if (httpRequest != null) {
    withMethod(httpRequest.getMethod());
    withPath(httpRequest.getPath());
    withQueryStringParameters(httpRequest.getQueryStringParameters());
    withBody(httpRequest.getBody());
    withHeaders(httpRequest.getHeaders());
    withCookies(httpRequest.getCookies());
    withKeepAlive(httpRequest.isKeepAlive());
    withSsl(httpRequest.isSecure());
  }
}

代码示例来源:origin: jamesdbloom/mockserver

public HttpRequestMatcher(Expectation expectation, MockServerLogger mockServerLogger) {
  this.expectation = expectation;
  this.httpRequest = expectation.getHttpRequest();
  this.mockServerLogger = mockServerLogger;
  if (httpRequest != null) {
    withMethod(httpRequest.getMethod());
    withPath(httpRequest.getPath());
    withQueryStringParameters(httpRequest.getQueryStringParameters());
    withBody(httpRequest.getBody());
    withHeaders(httpRequest.getHeaders());
    withCookies(httpRequest.getCookies());
    withKeepAlive(httpRequest.isKeepAlive());
    withSsl(httpRequest.isSecure());
  }
}

代码示例来源:origin: jamesdbloom/mockserver

);
assertEquals(StaticTestExpectationResponseCallback.httpRequests.get(0).getBody().getValue(), "an_example_body_http");
assertEquals(StaticTestExpectationResponseCallback.httpRequests.get(0).getPath().getValue(), calculatePath("callback"));
assertEquals(StaticTestExpectationResponseCallback.httpRequests.get(1).getPath().getValue(), calculatePath("callback"));

代码示例来源:origin: org.mock-server/mockserver-netty

@Override
  public void run() {
    KeyAndCertificateFactory.addSubjectAlternativeName(request.getPath().getValue());
  }
});

相关文章