Package com.github.tomakehurst.wiremock
Class WireMockServer
java.lang.Object
com.github.tomakehurst.wiremock.WireMockServer
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionWireMockServer(int port) WireMockServer(int port, FileSource fileSource, boolean enableBrowserProxying) WireMockServer(int port, FileSource fileSource, boolean enableBrowserProxying, ProxySettings proxySettings) WireMockServer(int port, Integer httpsPort) WireMockServer(int port, Integer httpsPort, FileSource fileSource, boolean enableBrowserProxying, ProxySettings proxySettings, Notifier notifier) WireMockServer(Options options) WireMockServer(String filenameTemplate) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddMessageStubMapping(MessageStubMapping messageStubMapping) Adds a message stub mapping that will be matched against incoming messages on channels.voidaddMockServiceRequestListener(RequestListener listener) voidaddStubMapping(StubMapping stubMapping) baseUrl()voidintcountMessageEventsMatching(MessagePattern pattern) Counts message events matching the given pattern.countRequestsMatching(RequestPattern requestPattern) voideditStub(MappingBuilder mappingBuilder) voideditStubMapping(StubMapping stubMapping) findAll(RequestPatternBuilder requestPatternBuilder) findAllMessageEvents(MessagePattern pattern) Gets message serve events matching the given pattern.Finds all message stub mappings matching the given metadata pattern.findAllNearMissesFor(RequestPatternBuilder requestPatternBuilder) findAllStubsByMetadata(StringValuePattern pattern) findMessageEventsMatching(MessagePattern pattern) Gets message events matching the given pattern.findNearMissesFor(LoggedRequest loggedRequest) findRequestsMatching(RequestPattern requestPattern) findTopNearMissesFor(RequestPattern requestPattern) findTopNearMissesFor(LoggedRequest loggedRequest) Gets all message serve events from the message journal.org.wiremock.url.BaseUrlGets a specific message serve event by ID.Gets all message serve events from the message journal.Gets all registered message stub mappings.getServedStub(UUID id) getServeEvents(ServeEventQuery query) getStubMapping(UUID id) givenThat(MappingBuilder mappingBuilder) intvoidimportStubs(StubImport stubImport) booleanbooleanbooleanLists all active message channels.Lists all message stub mappings.voidloadMappingsUsing(MappingsLoader mappingsLoader) voidloadMessageMappingsUsing(MappingsLoader mappingsLoader) messageStubFor(MessageStubMappingBuilder builder) Registers a message stub mapping using a builder.messageStubFor(MessageStubMapping messageStubMapping) Registers a message stub mapping directly.intport()voidremoveMessageServeEvent(UUID eventId) Removes a specific message serve event from the journal.Removes all message serve events for stubs matching the given metadata pattern.Removes all message serve events matching the given pattern.voidRemoves a message stub mapping.voidRemoves a message stub mapping by its ID.voidRemoves all message stub mappings matching the given metadata pattern.voidremoveServeEvent(UUID eventId) removeServeEventsForStubsMatchingMetadata(StringValuePattern metadataPattern) removeServeEventsMatching(RequestPattern requestPattern) voidremoveStub(MappingBuilder mappingBuilder) voidremoveStub(StubMapping stubMapping) voidremoveStub(UUID id) voidremoveStubMapping(StubMapping stubMapping) voidvoidremoveStubMappings(List<StubMapping> stubMappings) voidvoidremoveStubsByMetadata(StringValuePattern pattern) voidresetAll()voidvoidResets the message journal, removing all events.voidRemoves all message stub mappings.voidRemoves all message stub mappings.voidvoidresetScenario(String name) voidvoidorg.wiremock.url.AbsoluteUrlorg.wiremock.url.AbsoluteUrlresolve(org.wiremock.url.Path path) org.wiremock.url.AbsoluteUrlresolve(org.wiremock.url.RelativeUrl pathAndQuery) voidsendChannelMessage(ChannelType type, RequestPattern requestPattern, MessageDefinition message) Sends a message to all channels of the specified type matching the given request pattern.voidsetGlobalFixedDelay(int milliseconds) voidsetScenarioState(String name, String state) voidshutdown()Gracefully shutdown the server.voidsnapshotRecord(RecordSpec spec) voidstart()voidstartRecording(RecordSpec spec) voidstartRecording(RecordSpecBuilder recordSpec) voidstartRecording(String targetBaseUrl) voidstop()stubFor(MappingBuilder mappingBuilder) voidupdateGlobalSettings(GlobalSettings newSettings) voidverify(int count, RequestPatternBuilder requestPatternBuilder) voidverify(CountMatchingStrategy countMatchingStrategy, RequestPatternBuilder requestPatternBuilder) voidverify(RequestPatternBuilder requestPatternBuilder) voidverifyMessageEvent(int expectedCount, MessagePattern pattern) Verifies that exactly the specified number of message events match the given pattern.voidverifyMessageEvent(CountMatchingStrategy expectedCount, MessagePattern pattern) Verifies that the number of message events matching the pattern satisfies the count strategy.voidverifyMessageEvent(MessagePattern pattern) Verifies that at least one message event matches the given pattern.waitForMessageEvent(MessagePattern pattern, Duration maxWait) Waits for a message event matching the given pattern to appear in the journal.waitForMessageEvents(MessagePattern pattern, int count, Duration maxWait) Waits for a specific number of message events matching the given pattern.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.github.tomakehurst.wiremock.core.Admin
sendChannelMessage
-
Field Details
-
options
-
client
-
-
Constructor Details
-
WireMockServer
-
WireMockServer
public WireMockServer(int port, Integer httpsPort, FileSource fileSource, boolean enableBrowserProxying, ProxySettings proxySettings, Notifier notifier) -
WireMockServer
public WireMockServer(int port, FileSource fileSource, boolean enableBrowserProxying, ProxySettings proxySettings) -
WireMockServer
-
WireMockServer
public WireMockServer(int port) -
WireMockServer
-
WireMockServer
public WireMockServer() -
WireMockServer
-
-
Method Details
-
loadMappingsUsing
-
loadMessageMappingsUsing
-
addMockServiceRequestListener
-
stop
public void stop() -
startServer
-
start
public void start() -
shutdown
public void shutdown()Gracefully shutdown the server.This method assumes it is being called as the result of an incoming HTTP request.
-
isHttpEnabled
public boolean isHttpEnabled() -
isHttpsEnabled
public boolean isHttpsEnabled() -
port
public int port() -
httpsPort
public int httpsPort() -
url
-
resolve
-
resolve
public org.wiremock.url.AbsoluteUrl resolve(org.wiremock.url.RelativeUrl pathAndQuery) -
resolve
public org.wiremock.url.AbsoluteUrl resolve(org.wiremock.url.Path path) -
baseUrl
-
getBaseUrl
public org.wiremock.url.BaseUrl getBaseUrl() -
isRunning
public boolean isRunning() -
givenThat
-
stubFor
-
editStub
-
removeStub
- Specified by:
removeStubin interfaceStubbing
-
removeStub
- Specified by:
removeStubin interfaceStubbing
-
removeStub
- Specified by:
removeStubin interfaceStubbing
-
getStubMappings
- Specified by:
getStubMappingsin interfaceStubbing
-
getSingleStubMapping
- Specified by:
getSingleStubMappingin interfaceStubbing
-
findStubMappingsByMetadata
- Specified by:
findStubMappingsByMetadatain interfaceStubbing
-
removeStubMappingsByMetadata
- Specified by:
removeStubMappingsByMetadatain interfaceStubbing
-
removeStubMapping
- Specified by:
removeStubMappingin interfaceAdmin
-
removeStubMapping
- Specified by:
removeStubMappingin interfaceAdmin
-
verify
-
verify
-
verify
public void verify(CountMatchingStrategy countMatchingStrategy, RequestPatternBuilder requestPatternBuilder) -
findAll
-
getAllServeEvents
- Specified by:
getAllServeEventsin interfaceStubbing
-
setGlobalFixedDelay
public void setGlobalFixedDelay(int milliseconds) - Specified by:
setGlobalFixedDelayin interfaceStubbing
-
findAllUnmatchedRequests
- Specified by:
findAllUnmatchedRequestsin interfaceStubbing
-
findNearMissesForAllUnmatchedRequests
- Specified by:
findNearMissesForAllUnmatchedRequestsin interfaceStubbing
-
findAllNearMissesFor
- Specified by:
findAllNearMissesForin interfaceStubbing
-
findNearMissesFor
- Specified by:
findNearMissesForin interfaceStubbing
-
addStubMapping
- Specified by:
addStubMappingin interfaceAdmin
-
editStubMapping
- Specified by:
editStubMappingin interfaceAdmin
-
listAllStubMappings
- Specified by:
listAllStubMappingsin interfaceAdmin
-
getStubMapping
- Specified by:
getStubMappingin interfaceAdmin
-
saveMappings
public void saveMappings()- Specified by:
saveMappingsin interfaceAdmin
-
resetAll
public void resetAll() -
resetRequests
public void resetRequests()- Specified by:
resetRequestsin interfaceAdmin
-
resetToDefaultMappings
public void resetToDefaultMappings()- Specified by:
resetToDefaultMappingsin interfaceAdmin
-
getServeEvents
- Specified by:
getServeEventsin interfaceAdmin
-
getServeEvents
- Specified by:
getServeEventsin interfaceAdmin
-
getServedStub
- Specified by:
getServedStubin interfaceAdmin
-
resetScenarios
public void resetScenarios()- Specified by:
resetScenariosin interfaceAdmin
-
resetMappings
public void resetMappings()- Specified by:
resetMappingsin interfaceAdmin
-
countRequestsMatching
- Specified by:
countRequestsMatchingin interfaceAdmin
-
findRequestsMatching
- Specified by:
findRequestsMatchingin interfaceAdmin
-
findUnmatchedRequests
- Specified by:
findUnmatchedRequestsin interfaceAdmin
-
removeServeEvent
- Specified by:
removeServeEventin interfaceAdmin
-
removeServeEventsMatching
- Specified by:
removeServeEventsMatchingin interfaceAdmin
-
removeServeEventsForStubsMatchingMetadata
public FindServeEventsResult removeServeEventsForStubsMatchingMetadata(StringValuePattern metadataPattern) - Specified by:
removeServeEventsForStubsMatchingMetadatain interfaceAdmin
-
updateGlobalSettings
- Specified by:
updateGlobalSettingsin interfaceAdmin
-
findNearMissesForUnmatchedRequests
- Specified by:
findNearMissesForUnmatchedRequestsin interfaceAdmin
-
getAllScenarios
- Specified by:
getAllScenariosin interfaceAdmin
-
resetScenario
- Specified by:
resetScenarioin interfaceAdmin
-
setScenarioState
- Specified by:
setScenarioStatein interfaceAdmin
-
findTopNearMissesFor
- Specified by:
findTopNearMissesForin interfaceAdmin
-
findTopNearMissesFor
- Specified by:
findTopNearMissesForin interfaceAdmin
-
startRecording
- Specified by:
startRecordingin interfaceAdmin
-
startRecording
- Specified by:
startRecordingin interfaceAdmin
-
startRecording
- Specified by:
startRecordingin interfaceAdmin
-
stopRecording
- Specified by:
stopRecordingin interfaceAdmin
-
getRecordingStatus
- Specified by:
getRecordingStatusin interfaceAdmin
-
snapshotRecord
- Specified by:
snapshotRecordin interfaceAdmin
-
snapshotRecord
- Specified by:
snapshotRecordin interfaceAdmin
-
snapshotRecord
- Specified by:
snapshotRecordin interfaceAdmin
-
getOptions
- Specified by:
getOptionsin interfaceAdmin
-
shutdownServer
public void shutdownServer()- Specified by:
shutdownServerin interfaceAdmin
-
findUnmatchedStubs
- Specified by:
findUnmatchedStubsin interfaceAdmin
-
findAllStubsByMetadata
- Specified by:
findAllStubsByMetadatain interfaceAdmin
-
removeStubsByMetadata
- Specified by:
removeStubsByMetadatain interfaceAdmin
-
importStubs
- Specified by:
importStubsin interfaceAdmin
-
removeStubMappings
- Specified by:
removeStubMappingsin interfaceAdmin
-
getGlobalSettings
- Specified by:
getGlobalSettingsin interfaceAdmin
-
checkForUnmatchedRequests
public void checkForUnmatchedRequests() -
getLoadedExtensionNames
-
sendChannelMessage
public SendChannelMessageResult sendChannelMessage(ChannelType type, RequestPattern requestPattern, MessageDefinition message) Description copied from interface:AdminSends a message to all channels of the specified type matching the given request pattern.- Specified by:
sendChannelMessagein interfaceAdmin- Parameters:
type- the channel type to targetrequestPattern- the pattern to match against the original upgrade requestmessage- the message to send- Returns:
- result containing the matched channels that were messaged
-
listAllMessageChannels
Description copied from interface:AdminLists all active message channels.- Specified by:
listAllMessageChannelsin interfaceAdmin- Returns:
- result containing all message channels
-
addMessageStubMapping
Description copied from interface:AdminAdds a message stub mapping that will be matched against incoming messages on channels.- Specified by:
addMessageStubMappingin interfaceAdmin- Parameters:
messageStubMapping- the message stub mapping to add
-
removeMessageStubMapping
Description copied from interface:AdminRemoves a message stub mapping by its ID.- Specified by:
removeMessageStubMappingin interfaceAdmin- Parameters:
id- the ID of the message stub mapping to remove
-
resetMessageStubMappings
public void resetMessageStubMappings()Description copied from interface:AdminRemoves all message stub mappings.- Specified by:
resetMessageStubMappingsin interfaceAdmin
-
findAllMessageStubsByMetadata
Description copied from interface:AdminFinds all message stub mappings matching the given metadata pattern.- Specified by:
findAllMessageStubsByMetadatain interfaceAdmin- Parameters:
pattern- the pattern to match stub metadata against- Returns:
- result containing matching message stub mappings
-
removeMessageStubsByMetadata
Description copied from interface:AdminRemoves all message stub mappings matching the given metadata pattern.- Specified by:
removeMessageStubsByMetadatain interfaceAdmin- Parameters:
pattern- the pattern to match stub metadata against
-
listAllMessageStubMappings
Description copied from interface:AdminLists all message stub mappings.- Specified by:
listAllMessageStubMappingsin interfaceAdmin- Returns:
- result containing all message stub mappings
-
messageStubFor
Description copied from interface:StubbingRegisters a message stub mapping using a builder.- Specified by:
messageStubForin interfaceStubbing- Parameters:
builder- the message stub mapping builder- Returns:
- the registered MessageStubMapping
-
messageStubFor
Description copied from interface:StubbingRegisters a message stub mapping directly.- Specified by:
messageStubForin interfaceStubbing- Parameters:
messageStubMapping- the message stub mapping to register- Returns:
- the registered MessageStubMapping
-
removeMessageStub
Description copied from interface:StubbingRemoves a message stub mapping.- Specified by:
removeMessageStubin interfaceStubbing- Parameters:
id- the UUID of the message stub mapping to remove
-
getMessageStubMappingsList
Description copied from interface:StubbingGets all registered message stub mappings.- Specified by:
getMessageStubMappingsListin interfaceStubbing- Returns:
- list of all message stub mappings
-
resetMessageStubs
public void resetMessageStubs()Description copied from interface:StubbingRemoves all message stub mappings.- Specified by:
resetMessageStubsin interfaceStubbing
-
getMessageServeEvents
Description copied from interface:AdminGets all message serve events from the message journal.- Specified by:
getMessageServeEventsin interfaceAdmin- Returns:
- result containing all message serve events
-
getMessageServeEvent
Description copied from interface:AdminGets a specific message serve event by ID.- Specified by:
getMessageServeEventin interfaceAdmin- Parameters:
id- the event ID- Returns:
- the event if found
-
countMessageEventsMatching
Description copied from interface:AdminCounts message events matching the given pattern.- Specified by:
countMessageEventsMatchingin interfaceAdmin- Parameters:
pattern- the pattern to match events against- Returns:
- the count of matching events
-
findMessageEventsMatching
Description copied from interface:AdminGets message events matching the given pattern.- Specified by:
findMessageEventsMatchingin interfaceAdmin- Parameters:
pattern- the pattern to match events against- Returns:
- list of matching events
-
removeMessageServeEvent
Description copied from interface:AdminRemoves a specific message serve event from the journal.- Specified by:
removeMessageServeEventin interfaceAdmin- Parameters:
eventId- the ID of the event to remove
-
removeMessageServeEventsMatching
Description copied from interface:AdminRemoves all message serve events matching the given pattern.- Specified by:
removeMessageServeEventsMatchingin interfaceAdmin- Parameters:
pattern- the pattern to match events against- Returns:
- result containing the removed events
-
removeMessageServeEventsForStubsMatchingMetadata
public FindMessageServeEventsResult removeMessageServeEventsForStubsMatchingMetadata(StringValuePattern pattern) Description copied from interface:AdminRemoves all message serve events for stubs matching the given metadata pattern.- Specified by:
removeMessageServeEventsForStubsMatchingMetadatain interfaceAdmin- Parameters:
pattern- the pattern to match stub metadata against- Returns:
- result containing the removed events
-
resetMessageJournal
public void resetMessageJournal()Description copied from interface:StubbingResets the message journal, removing all events.- Specified by:
resetMessageJournalin interfaceAdmin- Specified by:
resetMessageJournalin interfaceStubbing
-
waitForMessageEvent
Description copied from interface:StubbingWaits for a message event matching the given pattern to appear in the journal.- Specified by:
waitForMessageEventin interfaceAdmin- Specified by:
waitForMessageEventin interfaceStubbing- Parameters:
pattern- the pattern to match events againstmaxWait- the maximum duration to wait- Returns:
- the matching event if found within the timeout
-
waitForMessageEvents
public List<MessageServeEvent> waitForMessageEvents(MessagePattern pattern, int count, Duration maxWait) Description copied from interface:StubbingWaits for a specific number of message events matching the given pattern.- Specified by:
waitForMessageEventsin interfaceAdmin- Specified by:
waitForMessageEventsin interfaceStubbing- Parameters:
pattern- the pattern to match events againstcount- the number of events to wait formaxWait- the maximum duration to wait- Returns:
- list of matching events
-
getAllMessageServeEvents
Description copied from interface:StubbingGets all message serve events from the message journal.- Specified by:
getAllMessageServeEventsin interfaceStubbing- Returns:
- list of all message serve events
-
findAllMessageEvents
Description copied from interface:StubbingGets message serve events matching the given pattern.- Specified by:
findAllMessageEventsin interfaceStubbing- Parameters:
pattern- the pattern to match events against- Returns:
- list of matching events
-
verifyMessageEvent
Description copied from interface:StubbingVerifies that at least one message event matches the given pattern.- Specified by:
verifyMessageEventin interfaceStubbing- Parameters:
pattern- the pattern to match events against
-
verifyMessageEvent
Description copied from interface:StubbingVerifies that exactly the specified number of message events match the given pattern.- Specified by:
verifyMessageEventin interfaceStubbing- Parameters:
expectedCount- the expected number of matching eventspattern- the pattern to match events against
-
verifyMessageEvent
Description copied from interface:StubbingVerifies that the number of message events matching the pattern satisfies the count strategy.- Specified by:
verifyMessageEventin interfaceStubbing- Parameters:
expectedCount- the count matching strategypattern- the pattern to match events against
-