• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java StubMapping类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: createObject

import com.github.tomakehurst.wiremock.stubbing.StubMapping; //导入依赖的package包/类
@Override
protected URL createObject(DeploymentEndpoints endpoints) {
    for(DeploymentEndpoints.Endpoint endpoint : endpoints.list()) {
        if(endpoint.getName().equals("wiremock-server")) {
            String host = endpoint.getHost();
            int port = endpoint.getPort();
            WireMock wireMock = new WireMock(host,port);
            wireMock.register(StubMapping.buildFrom(stubMapping));
            try {
                return new URL(String.format("http://%s:%s", host, port));
            } catch (MalformedURLException e) {
                return null;
            }
        }
    }
    return null;
}
 
开发者ID:LivePersonInc,项目名称:ephemerals,代码行数:18,代码来源:WireMockEphemeral.java


示例2: createIndex

import com.github.tomakehurst.wiremock.stubbing.StubMapping; //导入依赖的package包/类
/**
 * Test if the client can create an index
 * @param context the test context
 */
@Test
public void createIndex(TestContext context) {
  StubMapping settings = stubFor(put(urlEqualTo("/" + INDEX))
    .withRequestBody(equalTo(""))
    .willReturn(aResponse()
      .withBody(ACKNOWLEDGED.encode())
      .withStatus(200)));

  Async async = context.async();
  client.createIndex().subscribe(ok -> {
    context.assertTrue(ok);
    verify(putRequestedFor(settings.getRequest().getUrlMatcher()));
    async.complete();
  }, context::fail);
}
 
开发者ID:georocket,项目名称:georocket,代码行数:20,代码来源:RemoteElasticsearchClientTest.java


示例3: createIndexWithSettings

import com.github.tomakehurst.wiremock.stubbing.StubMapping; //导入依赖的package包/类
/**
 * Test if the client can create an index with settings
 * @param context the test context
 */
@Test
public void createIndexWithSettings(TestContext context) {
  StubMapping settings = stubFor(put(urlEqualTo("/" + INDEX))
    .withRequestBody(equalToJson(SETTINGS_WRAPPER.encode()))
    .willReturn(aResponse()
      .withBody(ACKNOWLEDGED.encode())
      .withStatus(200)));

  Async async = context.async();
  client.createIndex(SETTINGS).subscribe(ok -> {
    context.assertTrue(ok);
    verify(putRequestedFor(settings.getRequest().getUrlMatcher()));
    async.complete();
  }, context::fail);
}
 
开发者ID:georocket,项目名称:georocket,代码行数:20,代码来源:RemoteElasticsearchClientTest.java


示例4: filter

import com.github.tomakehurst.wiremock.stubbing.StubMapping; //导入依赖的package包/类
@Override
public Response filter(FilterableRequestSpecification requestSpec,
					   FilterableResponseSpecification responseSpec, FilterContext context) {
	Map<String, Object> configuration = getConfiguration(requestSpec, context);
	configuration.put("contract.jsonPaths", this.jsonPaths.keySet());
	Response response = context.next(requestSpec, responseSpec);
	if (requestSpec.getBody() != null && !this.jsonPaths.isEmpty()) {
		String actual = new String((byte[]) requestSpec.getBody());
		for (JsonPath jsonPath : this.jsonPaths.values()) {
			new JsonPathValue(jsonPath, actual).assertHasValue(Object.class,
					"an object");
		}
	}
	if (this.builder != null) {
		this.builder.willReturn(getResponseDefinition(response));
		StubMapping stubMapping = this.builder.build();
		MatchResult match = stubMapping.getRequest()
				.match(new WireMockRestAssuredRequestAdapter(requestSpec));
		assertThat(match.isExactMatch()).as("wiremock did not match request")
				.isTrue();
		configuration.put("contract.stubMapping", stubMapping);
	}
	return response;
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-netflix,代码行数:25,代码来源:RequestVerifierFilter.java


示例5: storeMappings

import com.github.tomakehurst.wiremock.stubbing.StubMapping; //导入依赖的package包/类
private void storeMappings(List<StubMapping> mappings) {
	try {
		File proxiedStubs = new File("target/stubs");
		proxiedStubs.mkdirs();
		for (StubMapping mapping : mappings) {
			File stub = new File(proxiedStubs, testName.getMethodName() + ".json");
			stub.createNewFile();
			Files.write(stub.toPath(), configure(mapping).toString().getBytes());
		}
	} catch (Exception e) {
		throw new RuntimeException(e);
	}
}
 
开发者ID:marcingrzejszczak,项目名称:the-legacy-app,代码行数:14,代码来源:AbstractStubsFromProxy.java


示例6: run

import com.github.tomakehurst.wiremock.stubbing.StubMapping; //导入依赖的package包/类
private void run(String... args) {

        String[] argsWithExtensions = applyExtensions(args);
        CommandLineOptions options = new CommandLineOptions(argsWithExtensions);
        if (options.help()) {
            out.println(options.helpText());
            return;
        }

        FileSource fileSource = options.filesRoot();
        fileSource.createIfNecessary();
        FileSource filesFileSource = fileSource.child(FILES_ROOT);
        filesFileSource.createIfNecessary();
        FileSource mappingsFileSource = fileSource.child(MAPPINGS_ROOT);
        mappingsFileSource.createIfNecessary();


        WireMockServer wireMockServer = new WireMockServer(options);
        if (options.recordMappingsEnabled()) {
            wireMockServer.enableRecordMappings(mappingsFileSource, filesFileSource);
        }
        wireMockServer.setGlobalFixedDelay(50);

        try {
            wireMockServer.start();
            out.println(BANNER);
            out.println();
            out.println(options);
            addMappings(wireMockServer);

            out.println("Mock server contains next mappings:");
            for (StubMapping mapping : wireMockServer.listAllStubMappings().getMappings()) {
                out.println(mapping.toString());
            }

        } catch (FatalStartupException e) {
            System.err.println(e.getMessage());
            System.exit(1);
        }
    }
 
开发者ID:webdizz,项目名称:web-scale-perf-testing,代码行数:41,代码来源:PatientApiServer.java


示例7: build

import com.github.tomakehurst.wiremock.stubbing.StubMapping; //导入依赖的package包/类
public StubMapping build() {
	RequestPattern requestPattern = new RequestPattern(method, url);
	ResponseDefinition response = new ResponseDefinition(responseStatus, responseBody);
	response.setHeaders(new HttpHeaders(headers));
	StubMapping mapping = new StubMapping(requestPattern, response);
	return mapping;
}
 
开发者ID:OfficeDev,项目名称:orc-for-android,代码行数:8,代码来源:RequestResponseMappingBuilder.java


示例8: ExternalServicesStub

import com.github.tomakehurst.wiremock.stubbing.StubMapping; //导入依赖的package包/类
ExternalServicesStub(IngredientsProperties ingredientsProperties) throws IOException {
    URI uri = URI.create(ingredientsProperties.getRootUrl());
    this.wireMockServer = new WireMockServer(WireMockConfiguration.wireMockConfig()
            .port(uri.getPort()));
    wireMockServer.addStubMapping(StubMapping.buildFrom(
            IOUtils.toString(ExternalServicesStub.class.getResourceAsStream("/mappings/chmieleo.json"))));
    wireMockServer.addStubMapping(StubMapping.buildFrom(
            IOUtils.toString(ExternalServicesStub.class.getResourceAsStream("/mappings/drozdzeo.json"))));
    wireMockServer.addStubMapping(StubMapping.buildFrom(
            IOUtils.toString(ExternalServicesStub.class.getResourceAsStream("/mappings/slodeo.json"))));
    wireMockServer.addStubMapping(StubMapping.buildFrom(
            IOUtils.toString(ExternalServicesStub.class.getResourceAsStream("/mappings/wodeo.json"))));
}
 
开发者ID:2015-06-devoxx-microservices,项目名称:aggregatr.io,代码行数:14,代码来源:ExternalServicesStub.java


示例9: tearDown

import com.github.tomakehurst.wiremock.stubbing.StubMapping; //导入依赖的package包/类
@After
public void tearDown() {
	SnapshotRecordResult recording = WireMock.stopRecording();
	List<StubMapping> mappings = recording.getStubMappings();
	storeMappings(mappings);
}
 
开发者ID:marcingrzejszczak,项目名称:the-legacy-app,代码行数:7,代码来源:AbstractStubsFromProxy.java


示例10: should_print_wiremock_mappings

import com.github.tomakehurst.wiremock.stubbing.StubMapping; //导入依赖的package包/类
@Test
public void should_print_wiremock_mappings() {
	List<StubMapping> mappings = server.listAllStubMappings().getMappings();
	System.out.println("\n\nRegistered WireMock Mappings:\n" + mappings);
	assertEquals(11, mappings.size());
}
 
开发者ID:ePages-de,项目名称:restdocs-wiremock,代码行数:7,代码来源:NoteServiceTest.java


示例11: configure

import com.github.tomakehurst.wiremock.stubbing.StubMapping; //导入依赖的package包/类
/**
 * Perform additional customization of the stored {@link StubMapping}.
 * E.g. find a timestamp field and change that into a regular expression.
 */
protected StubMapping configure(StubMapping stubMapping) {
	return stubMapping;
}
 
开发者ID:marcingrzejszczak,项目名称:the-legacy-app,代码行数:8,代码来源:AbstractStubsFromProxy.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java EntityManagerFactoryBuilder类代码示例发布时间:2022-05-23
下一篇:
Java SVcsModification类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap