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


Java Request类代码示例

本文整理汇总了Java中com.github.tomakehurst.wiremock.http.Request的典型用法代码示例。如果您正苦于以下问题:Java Request类的具体用法?Java Request怎么用?Java Request使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Request类属于com.github.tomakehurst.wiremock.http包,在下文中一共展示了Request类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: transform

import com.github.tomakehurst.wiremock.http.Request; //导入依赖的package包/类
@Override
public ResponseDefinition transform(Request request, ResponseDefinition responseDefinition,
    FileSource files, Parameters parameters) {
  MockParameters params = (MockParameters) parameters.get(UnitStackTest.MOCK_PARAMS);
  Map<String, String> body = new HashMap<>();
  String method = request.getMethod().getName();
  byte[] fileContent = null;
  body.put(PARAMETER_URL_NAME, request.getAbsoluteUrl());
  body.put(PARAMETER_METHOD, method);
  if (method.equals("GET")) {
    body.put(ACTION, StringUtils.substringAfter(request.getAbsoluteUrl(), "?"));
  } else {
    body.put(PARAMETER_RESPONSE_XML, request.getBodyAsString());
    fileContent = request.getBody();
  }
  body.putAll(getHeaders(request));

  MockResponse response = s3Responder.createResponse(
      new MockRequest(body, params, utils).withBuckets(buckets).withFileContent(fileContent));

  return createResponse(response);
}
 
开发者ID:daflockinger,项目名称:unitstack,代码行数:23,代码来源:S3RequestTransformer.java

示例2: transform

import com.github.tomakehurst.wiremock.http.Request; //导入依赖的package包/类
@Override
public ResponseDefinition transform(Request request,
                                    ResponseDefinition responseDefinition,
                                    FileSource files,
                                    Parameters parameters) {


  ResponseDefinitionBuilder builder = new ResponseDefinitionBuilder().like(responseDefinition);
  String templatePath   = responseDefinition.getBodyFileName();

  if (templatePath != null && templatePath.contains(".template")) {
    try {
      Map scope = new ResponseScope(session, new HashMap(this.config), RequestReader.read(request));
      responseWriter = responseWriter == null ? new ResponseWriter(files.getPath()) : responseWriter;
      new BeforeBlock().run(responseDefinition, scope);
      responseWriter.writeTo(builder, scope, templatePath);
    } catch (Exception e) {
      String errorMessage = "************* Jeyson Error *******************" + System.getProperty("line.separator");
      errorMessage += e.getMessage() + System.getProperty("line.separator");
      System.err.println(errorMessage);
      e.printStackTrace();
    }
  }

  return builder.build();
}
 
开发者ID:nishants,项目名称:wirestub,代码行数:27,代码来源:JeysonWiremock.java

示例3: transform

import com.github.tomakehurst.wiremock.http.Request; //导入依赖的package包/类
@Override
public ResponseDefinition transform(Request request,
                                    ResponseDefinition responseDefinition,
                                    FileSource files,
                                    Parameters parameters) {


  ResponseDefinitionBuilder builder = new ResponseDefinitionBuilder().like(responseDefinition);
  String templatePath   = responseDefinition.getBodyFileName();

  if (templatePath != null) {
    try {
      Map scope = new ResponseScope(session, new HashMap(this.config), RequestReader.read(request));
      responseWriter = responseWriter == null ? new ResponseWriter(files.getPath()) : responseWriter;
      new BeforeBlock().run(responseDefinition, scope);
      responseWriter.writeTo(builder, scope, templatePath);
    } catch (Exception e) {
      String errorMessage = "************* Jeyson Error *******************" + System.getProperty("line.separator");
      errorMessage += e.getMessage() + System.getProperty("line.separator");
      System.err.println(errorMessage);
      e.printStackTrace();
    }
  }

  return builder.build();
}
 
开发者ID:nishants,项目名称:wirestub,代码行数:27,代码来源:JeysoneWiremockException.java

示例4: setupWireMock

import com.github.tomakehurst.wiremock.http.Request; //导入依赖的package包/类
@Before
public void setupWireMock() throws Exception {
  String fusionHostAndPort = "http://" + fusionHost + fusionApiPort;

  fusionPipelineUrlWithoutHostAndPort = fusionProxyBaseUrl + fusionIndexingPipelineUrlExtension +
          fusionIndexingPipeline + fusionCollectionApiStrValForUrl + fusionCollectionForUrl +
          defaultFusionIndexingPipelineUrlTerminatingString;
  fusionUrl = fusionHostAndPort + fusionPipelineUrlWithoutHostAndPort;
  fusionSolrProxyWithoutHostAndPort = fusionSolrProxyUrlExtension + fusionCollectionForUrl;

  wireMockRule.addMockServiceRequestListener(new RequestListener() {
    @Override
    public void requestReceived(Request request, Response response) {
      loggedRequests.add(LoggedRequest.createFrom(request));
    }
  });

  log.info("running with: fusionSolrProxyWithoutHostAndPort=" + fusionSolrProxyWithoutHostAndPort +
          " fusionPipelineUrlWithoutHostAndPort=" + fusionPipelineUrlWithoutHostAndPort +
          " wireMockRulePort=" + wireMockRulePort + " useWireMockRule=" + useWireMockRule);
}
 
开发者ID:lucidworks,项目名称:solr-hadoop-common,代码行数:22,代码来源:FusionPipelineClientTest.java

示例5: transform

import com.github.tomakehurst.wiremock.http.Request; //导入依赖的package包/类
@Override
public ResponseDefinition transform(final Request request,
        final ResponseDefinition responseDefinition, final FileSource files,
        final Parameters parameters) {
            if (responseDefinition.specifiesBodyFile() && templateDeclared(responseDefinition)) {
                  this.fileSource = files;
                  final VelocityEngine velocityEngine = new VelocityEngine();
                  velocityEngine.init();
                  final ToolManager toolManager = new ToolManager();
                  toolManager.setVelocityEngine(velocityEngine);
                  context = toolManager.createContext();
                  addBodyToContext(request.getBodyAsString());
                  addHeadersToContext(request.getHeaders());
                  context.put("requestAbsoluteUrl", request.getAbsoluteUrl());
                  context.put("requestUrl", request.getUrl());
                  context.put("requestMethod", request.getMethod());
                  final String body = getRenderedBody(responseDefinition);
                  return ResponseDefinitionBuilder.like(responseDefinition).but()
                          .withBody(body)
                          .build();
            } else {
                return responseDefinition;
            }
}
 
开发者ID:adamyork,项目名称:wiremock-velocity-transformer,代码行数:25,代码来源:VelocityResponseTransformer.java

示例6: getClaimsFromRequest

import com.github.tomakehurst.wiremock.http.Request; //导入依赖的package包/类
private JwtClaims getClaimsFromRequest(Request request) throws Exception {

        // Get the JWT out of the request body
        String body = request.getBodyAsString();
        String[] tokens = body.split("&");
        String jwt = null;
        for (String s : tokens) {
            String[] parts = s.split("=");
            if (parts[0] != null && parts[0].equals("assertion") && parts[1] != null) {
                jwt = parts[1];
            }
        }
        if (jwt == null) {
            throw new Exception("No jwt assertion found in request body");
        }

        // Parse out the JWT to verify the claims
        JwtConsumer jwtConsumer = new JwtConsumerBuilder()
                .setSkipSignatureVerification()
                .setSkipAllValidators()
                .build();
        return jwtConsumer.processToClaims(jwt);
    }
 
开发者ID:box,项目名称:box-java-sdk,代码行数:24,代码来源:BoxDeveloperEditionAPIConnectionTest.java

示例7: RootConfigHandler

import com.github.tomakehurst.wiremock.http.Request; //导入依赖的package包/类
public RootConfigHandler(final Request request, final Parameters transformerParameters) throws WireMockCsvException {
	this.request = request;
	this.requestParams = RequestTemplateModel.from(request).getQuery();
	this.transformerParameters = transformerParameters;
	@SuppressWarnings("unchecked")
	final Map<String, Map<String, Object>> customParametersConfig =
	(Map<String, Map<String, Object>>) this.transformerParameters.get("customParameters");
	this.initCustomParameters(customParametersConfig);
}
 
开发者ID:massamany,项目名称:WireMockCsv,代码行数:10,代码来源:ConfigHandler.java

示例8: transform

import com.github.tomakehurst.wiremock.http.Request; //导入依赖的package包/类
@Override
public ResponseDefinition transform(Request request, ResponseDefinition responseDefinition,
    FileSource files, Parameters parameters) {
  MockParameters params = (MockParameters) parameters.get(UnitStackTest.MOCK_PARAMS);
  Map<String, String> body = utils.queryStringToMap(request.getBodyAsString());
  MockResponse response =
      snsResponder.createResponse(new MockRequest(body, params, utils).withTopics(topics));

  return new ResponseDefinitionBuilder().withBody(response.getBody())
      .withStatus(response.getStatus()).build();
}
 
开发者ID:daflockinger,项目名称:unitstack,代码行数:12,代码来源:SnsRequestTransformer.java

示例9: transform

import com.github.tomakehurst.wiremock.http.Request; //导入依赖的package包/类
@Override
public ResponseDefinition transform(Request request, ResponseDefinition responseDefinition,
    FileSource files, Parameters parameters) {
  MockParameters params = (MockParameters) parameters.get(UnitStackTest.MOCK_PARAMS);
  Map<String, String> body = new HashMap<>(utils.queryStringToMap(request.getBodyAsString()));
  body.put(PARAMETER_URL_NAME, request.getUrl());

  MockResponse response =
      sqsResponder.createResponse(new MockRequest(body, params, utils).withQueues(queues));

  return new ResponseDefinitionBuilder().withBody(response.getBody())
      .withStatus(response.getStatus()).build();
}
 
开发者ID:daflockinger,项目名称:unitstack,代码行数:14,代码来源:SqsRequestTransformer.java

示例10: read

import com.github.tomakehurst.wiremock.http.Request; //导入依赖的package包/类
public static Map read(Request request) throws IOException {
  if(request.getMethod().getName().equals("GET")){
    return new social.amoeba.jeyson.wiremock.request.Request(request);
  }
  ContentTypeHeader contentType = request.getHeaders().getContentTypeHeader();
  String mimeType = contentType == null ? null : contentType.mimeTypePart();
  boolean isJSON = contentType != null && mimeType.equalsIgnoreCase("application/json"),
          isXML  = contentType != null &&mimeType.equalsIgnoreCase("application/xml") || mimeType.equalsIgnoreCase("text/xml");

  return isXML ? new XMLRequest(request) : isJSON ? new JSONRequest(request) : new HashMap<>();
}
 
开发者ID:nishants,项目名称:wirestub,代码行数:12,代码来源:RequestReader.java

示例11: transform

import com.github.tomakehurst.wiremock.http.Request; //导入依赖的package包/类
@Override
public ResponseDefinition transform(final Request request, final ResponseDefinition responseDefinition, final FileSource files) {
    String patientHashedId = request.getUrl().replace("/patients/", "");
    final Patient patientEntity = createPatient(patientHashedId);
    try {
        responseDefinition.setBody(mapper.writeValueAsString(patientEntity));
    } catch (JsonProcessingException jpe) {
        LOGGER.error("Unable to convert patient to JSON string", jpe);
    }
    return responseDefinition;
}
 
开发者ID:webdizz,项目名称:web-scale-perf-testing,代码行数:12,代码来源:PatientResponseTransformer.java

示例12: addMockRequestListener

import com.github.tomakehurst.wiremock.http.Request; //导入依赖的package包/类
public static void addMockRequestListener(final WireMockRule rule, final List<Request> wiremockRequests) {
	//Handy WireMock listener that stores each request received
			rule.addMockServiceRequestListener(new RequestListener() {
			     @Override
			     public void requestReceived(Request request, Response response) {
			    	 wiremockRequests.add(LoggedRequest.createFrom(request));
			     }
			});
}
 
开发者ID:buildscientist,项目名称:wiremock-demo,代码行数:10,代码来源:WireMockUtils.java

示例13: transform

import com.github.tomakehurst.wiremock.http.Request; //导入依赖的package包/类
@Override
public ResponseDefinition transform(Request request, ResponseDefinition responseDefinition, FileSource files) {
	System.out.println("Transforming placeholders in " + request.getUrl());
	String responseBody = responseDefinition.getBody();
	if (responseDefinition.getBodyFileName() != null) {
		responseBody = new String(files.getBinaryFileNamed(responseDefinition.getBodyFileName()).readContents(),
				Charset.defaultCharset());
	}
	return ResponseDefinitionBuilder.like(responseDefinition).but().withBody(this.transformResponse(request, responseBody)).build();
}
 
开发者ID:jberrueta,项目名称:wiremock-extensions,代码行数:11,代码来源:PlaceholderTransformer.java

示例14: transformResponse

import com.github.tomakehurst.wiremock.http.Request; //导入依赖的package包/类
private String transformResponse(Request request, String response) {
	Matcher matcher = PATTERN.matcher(response);
	String requestBody = request.getBodyAsString();
	Map<String, String> placeholders = Maps.newHashMap();
	while (matcher.find()) {
		String placeholder = matcher.group();
		if (!placeholders.containsKey(placeholder)) {
			String value = this.lookupValue(placeholder, request, requestBody);
			System.out.println("Placeholder " + placeholder + " will be replace with value " + value);
			placeholders.put(placeholder, value);
		}
	}
	return StringUtils.replaceEach(response, placeholders.keySet().toArray(new String[] {}),
			placeholders.values().toArray(new String[] {}));
}
 
开发者ID:jberrueta,项目名称:wiremock-extensions,代码行数:16,代码来源:PlaceholderTransformer.java

示例15: lookupQueryParamValue

import com.github.tomakehurst.wiremock.http.Request; //导入依赖的package包/类
private String lookupQueryParamValue(String property, Request request) {
	QueryParameter queryParameter = request.queryParameter(property);
	if (queryParameter.isPresent()) {
		System.out.println("Placeholder found in query params");
		return Strings.join(queryParameter.values(), ",");
	}
	return null;
}
 
开发者ID:jberrueta,项目名称:wiremock-extensions,代码行数:9,代码来源:PlaceholderTransformer.java


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