Package ai.platon.pulsar.test.server
Object MockSiteLauncher
-
- All Implemented Interfaces:
-
java.io.Closeable,java.lang.AutoCloseable
public class MockSiteLauncher implements Closeable
Utility launcher to programmatically start / stop the MockSiteApplication.
Improvements:
Honors the explicit port argument by using a command-line arg
--server.port=(highest precedence)If already running on a different port, can optionally restart to match the requested port
-
-
Field Summary
Fields Modifier and Type Field Description public final static MockSiteLauncherINSTANCE
-
Method Summary
Modifier and Type Method Description final BooleanisRunning()Whether the mock site is currently running. final Integerport()The port the server actually bound to (null if not started). final StringbaseUrl()Base URL (null if not started). final ConfigurableApplicationContextstart(Integer port, Map<String, Object> properties, Array<String> profiles, Boolean headless, Boolean enforcePort)Start the mock site if not already started or restart if running on a different port and enforcePort is true. final ConfigurableApplicationContextrestart(Integer port, Map<String, Object> properties)Restart the server: stops if running, then starts again. final BooleanawaitReady(Duration timeout, Duration interval, String healthPath)Wait until the health endpoint (default "/actuator/health") responds with a 2xx/3xx status or timeout reached. final Unitstop()Stop the server if running. Unitclose()-
-
Method Detail
-
start
@Synchronized() final ConfigurableApplicationContext start(Integer port, Map<String, Object> properties, Array<String> profiles, Boolean headless, Boolean enforcePort)
Start the mock site if not already started or restart if running on a different port and enforcePort is true.
- Parameters:
port- Desired port (0 for random).enforcePort- If true and already running on a different port, the server is restarted on the requested port.
-
restart
@Synchronized() final ConfigurableApplicationContext restart(Integer port, Map<String, Object> properties)
Restart the server: stops if running, then starts again.
-
awaitReady
final Boolean awaitReady(Duration timeout, Duration interval, String healthPath)
Wait until the health endpoint (default "/actuator/health") responds with a 2xx/3xx status or timeout reached. Falls back to root "/" if health path not available.
- Returns:
true if ready, false if timed out.
-
stop
@Synchronized() final Unit stop()
Stop the server if running.
-
-
-
-