WireMock is a comprehensive API mocking and service virtualization library for testing and development environments with HTTP server simulation capabilities.
Command-line interface for running WireMock as a standalone service with comprehensive configuration options including server ports, SSL settings, proxy configuration, recording capabilities, and performance tuning.
Main server runner class providing lifecycle management for standalone WireMock instances.
/**
* Main server runner for standalone WireMock instances
*/
class WireMockServerRunner {
/** Default constructor */
WireMockServerRunner();
/** Start WireMock server with command-line arguments */
void run(String... args);
/** Stop the running server */
void stop();
/** Check if server is currently running */
boolean isRunning();
/** Get the port number server is listening on */
int port();
}Usage Examples:
// Programmatic server control
WireMockServerRunner runner = new WireMockServerRunner();
runner.run("--port", "8080", "--https-port", "8443");
// Server is now running
assertTrue(runner.isRunning());
assertEquals(8080, runner.port());
// Stop when done
runner.stop();
assertFalse(runner.isRunning());Main class for standalone JAR execution extending WireMockServerRunner.
/**
* Main entry point for standalone JAR execution
*/
class Run extends WireMockServerRunner {
/** Main method for command-line execution */
static void main(String... args);
}Usage Examples:
# Basic server startup
java -jar wiremock-standalone-3.13.1.jar
# Server with specific port
java -jar wiremock-standalone-3.13.1.jar --port 8089
# Server with HTTPS
java -jar wiremock-standalone-3.13.1.jar --port 8080 --https-port 8443Comprehensive command-line options parser implementing the full Options interface.
/**
* Command-line options parser and configuration manager
*/
class CommandLineOptions implements Options {
/** Parse command-line arguments into configuration */
CommandLineOptions(String... args);
// Help and Version
/** Check if help was requested */
boolean help();
/** Check if version info was requested */
boolean version();
/** Get formatted help text */
String helpText();
// Logging and Output
/** Check if verbose logging is enabled */
boolean verboseLoggingEnabled();
/** Check if startup banner is disabled */
boolean bannerDisabled();
// Recording and Proxy
/** Check if mapping recording is enabled */
boolean recordMappingsEnabled();
/** Check if proxy URL was specified */
boolean specifiesProxyUrl();
/** Get configured proxy URL */
String proxyUrl();
// Port Configuration (Runtime)
/** Set actual HTTP port after server startup */
void setActualHttpPort(int port);
/** Set actual HTTPS port after server startup */
void setActualHttpsPort(int port);
// Inherits all Options interface methods (70+ configuration options)
}Complete reference for all supported command-line arguments.
# Port Configuration
--port <port> # HTTP port (default: 8080)
--https-port <port> # HTTPS port
--bind-address <address> # Bind address (default: 0.0.0.0)
--container-threads <count> # Container thread pool size
--jetty-acceptor-threads <count> # Jetty acceptor threads
--jetty-accept-queue-size <size> # Jetty accept queue size
--jetty-header-buffer-size <size> # HTTP header buffer size
--async-response-enabled # Enable asynchronous responses
--async-response-threads <count> # Async response thread pool size
# Protocol Configuration
--disable-http # Disable HTTP protocol
--require-https # Require HTTPS for admin API# Keystore Configuration
--https-keystore <path> # Keystore file path
--keystore-password <password> # Keystore password
--keystore-type <type> # Keystore type (JKS, PKCS12)
--key-manager-password <password> # Key manager password
# Truststore Configuration
--https-truststore <path> # Truststore file path
--truststore-password <password> # Truststore password
--truststore-type <type> # Truststore type
# Client Authentication
--https-require-client-cert # Require client certificates# Basic Proxy Settings
--proxy-all <url> # Proxy all unmatched requests to URL
--proxy-via <host:port> # Proxy via intermediate proxy
--preserve-host-header # Preserve original host header
--proxy-pass-through # Enable proxy pass-through mode
# Proxy Security
--trust-all-proxy-targets # Trust all proxy target hosts
--trusted-proxy-targets <hosts> # Comma-separated trusted hosts
--ca-keystore <path> # CA keystore for proxy SSL
--ca-keystore-password <pwd> # CA keystore password
--ca-keystore-type <type> # CA keystore type# Directory Configuration
--root-dir <path> # Root directory for files
--mappings-dir <path> # Directory for stub mappings
--files-dir <path> # Directory for response files
# File Behavior
--no-request-journal # Disable request journaling
--max-request-journal-entries <count> # Limit journal entries
--record-mappings # Record proxy mappings to files
--match-headers <headers> # Headers to record for matching# Extensions
--extensions <class1,class2> # Load extension classes
--extension-scan-enabled # Enable classpath extension scanning
# Template Configuration
--global-response-templating # Enable global response templating
--local-response-templating # Enable per-stub templating
--max-template-cache-entries <count> # Template cache size
# Performance and Behavior
--disable-gzip # Disable gzip compression
--disable-request-logging # Disable request logging
--enable-stub-cors # Enable CORS for stub responses
--disable-optimize-xml-factories # Disable XML factory optimization
--disable-strict-http-headers # Disable strict HTTP header validation# Recording Configuration
--record-mappings # Enable mapping recording
--match-headers <headers> # Headers to include in recorded mappings
--proxy-all <target-url> # Record from existing API
# Monitoring and Debugging
--verbose # Enable verbose logging
--print-all-network-traffic # Log all network traffic
--no-banner # Disable startup banner# Admin API Authentication
--admin-api-username <user> # Admin API username
--admin-api-password <pass> # Admin API password
--admin-api-require-https # Require HTTPS for admin API# Basic standalone server
java -jar wiremock-standalone-3.13.1.jar --port 8080
# HTTPS-enabled server with custom keystore
java -jar wiremock-standalone-3.13.1.jar \
--port 8080 \
--https-port 8443 \
--https-keystore /path/to/keystore.jks \
--keystore-password secret123 \
--keystore-type JKS
# Proxy mode with recording
java -jar wiremock-standalone-3.13.1.jar \
--port 8080 \
--proxy-all https://api.example.com \
--record-mappings \
--match-headers Accept,Content-Type,Authorization
# High-performance configuration
java -jar wiremock-standalone-3.13.1.jar \
--port 8080 \
--container-threads 50 \
--jetty-acceptor-threads 4 \
--jetty-accept-queue-size 500 \
--async-response-enabled \
--async-response-threads 10
# Custom file locations
java -jar wiremock-standalone-3.13.1.jar \
--port 8080 \
--root-dir /opt/wiremock \
--mappings-dir /opt/wiremock/mappings \
--files-dir /opt/wiremock/__files
# Security-focused setup
java -jar wiremock-standalone-3.13.1.jar \
--port 8080 \
--https-port 8443 \
--require-https \
--admin-api-username admin \
--admin-api-password secret \
--https-require-client-cert \
--https-keystore server.jks \
--keystore-password serverpass \
--https-truststore truststore.jks \
--truststore-password trustpass
# Development mode with extensions
java -jar wiremock-standalone-3.13.1.jar \
--port 8080 \
--verbose \
--global-response-templating \
--extensions com.example.CustomTransformer \
--extension-scan-enabled \
--print-all-network-traffic
# Proxy with custom settings
java -jar wiremock-standalone-3.13.1.jar \
--port 8080 \
--proxy-all https://backend.example.com \
--proxy-via proxy.company.com:3128 \
--preserve-host-header \
--trusted-proxy-targets backend.example.com,api.example.com \
--ca-keystore ca-certs.jks \
--ca-keystore-password capass
# Help and version information
java -jar wiremock-standalone-3.13.1.jar --help
java -jar wiremock-standalone-3.13.1.jar --versionWhile primarily command-line focused, WireMock supports configuration through:
# Environment variables (example)
WIREMOCK_PORT=8080
WIREMOCK_HTTPS_PORT=8443
java -jar wiremock-standalone-3.13.1.jar
# System properties
java -Dwiremock.port=8080 -Dwiremock.https-port=8443 \
-jar wiremock-standalone-3.13.1.jar
# Property files and JSON configuration (when using file-based mappings)
# Mappings directory structure:
# /mappings/
# ├── mapping1.json
# ├── mapping2.json
# /__files/
# ├── response1.json
# ├── response2.xml# Systemd service example
[Unit]
Description=WireMock API Mock Server
After=network.target
[Service]
Type=simple
User=wiremock
WorkingDirectory=/opt/wiremock
ExecStart=/usr/bin/java -jar /opt/wiremock/wiremock-standalone-3.13.1.jar \
--port 8080 \
--https-port 8443 \
--root-dir /opt/wiremock/data
Restart=always
RestartSec=10
[Install]
WantedBy=multi-user.target
# Docker usage
docker run -it --rm \
-p 8080:8080 \
-p 8443:8443 \
-v $PWD/mappings:/home/wiremock/mappings \
-v $PWD/__files:/home/wiremock/__files \
wiremock/wiremock:3.13.1 \
--port 8080 \
--https-port 8443 \
--global-response-templating# Exit codes
# 0 - Success
# 1 - General error (invalid arguments, startup failure)
# 2 - Invalid arguments or configuration
# 130 - Interrupted (Ctrl+C)
# Error scenarios
java -jar wiremock-standalone-3.13.1.jar --invalid-option
# Returns exit code 2 with error message
java -jar wiremock-standalone-3.13.1.jar --port 80
# May return exit code 1 if port binding fails (requires root)Install with Tessl CLI
npx tessl i tessl/maven-org-wiremock--wiremock