W3Cschool
恭喜您成為首批注冊用戶
獲得88經(jīng)驗值獎勵
您可以為主類設(shè)置以下選項:
-c, --classifier Suffix for the jar containing stubs (e. g. 'stubs' if the stub jar would have a 'stubs' classifier for stubs: foobar-stubs ). Defaults to 'stubs' (default: stubs) --maxPort, --maxp <Integer> Maximum port value to be assigned to the WireMock instance. Defaults to 15000 (default: 15000) --minPort, --minp <Integer> Minimum port value to be assigned to the WireMock instance. Defaults to 10000 (default: 10000) -p, --password Password to user when connecting to repository --phost, --proxyHost Proxy host to use for repository requests --pport, --proxyPort [Integer] Proxy port to use for repository requests -r, --root Location of a Jar containing server where you keep your stubs (e.g. http: //nexus. net/content/repositories/repository) -s, --stubs Comma separated list of Ivy representation of jars with stubs. Eg. groupid:artifactid1,groupid2: artifactid2:classifier --sm, --stubsMode Stubs mode to be used. Acceptable values [CLASSPATH, LOCAL, REMOTE] -u, --username Username to user when connecting to repository
存根在JSON文檔中定義,其語法在WireMock文檔中定義
例:
{ "request": { "method": "GET", "url": "/ping" }, "response": { "status": 200, "body": "pong", "headers": { "Content-Type": "text/plain" } } }
每個存根協(xié)作者都會在__/admin/
端點下公開已定義映射的列表。
您還可以使用mappingsOutputFolder
屬性將映射轉(zhuǎn)儲到文件。對于基于注釋的方法,它看起來像這樣
@AutoConfigureStubRunner(ids="a.b.c:loanIssuance,a.b.c:fraudDetectionServer", mappingsOutputFolder = "target/outputmappings/")
對于這樣的JUnit方法:
@ClassRule @Shared StubRunnerRule rule = new StubRunnerRule() .repoRoot("http://some_url") .downloadStub("a.b.c", "loanIssuance") .downloadStub("a.b.c:fraudDetectionServer") .withMappingsOutputFolder("target/outputmappings")
然后,如果您檢出文件夾target/outputmappings
,則會看到以下結(jié)構(gòu)
. ├── fraudDetectionServer_13705 └── loanIssuance_12255
這意味著注冊了兩個存根。fraudDetectionServer
在端口13705
上注冊,loanIssuance
在端口12255
上注冊。如果我們看一下其中一個文件,我們將看到(對于WireMock)可用于給定服務(wù)器的映射:
[{ "id" : "f9152eb9-bf77-4c38-8289-90be7d10d0d7", "request" : { "url" : "/name", "method" : "GET" }, "response" : { "status" : 200, "body" : "fraudDetectionServer" }, "uuid" : "f9152eb9-bf77-4c38-8289-90be7d10d0d7" }, ... ]
Copyright©2021 w3cschool編程獅|閩ICP備15016281號-3|閩公網(wǎng)安備35020302033924號
違法和不良信息舉報電話:173-0602-2364|舉報郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號
聯(lián)系方式:
更多建議: