Class TestServer

java.lang.Object
io.fluxzero.testserver.TestServer

public class TestServer extends Object
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    main(String[] args)
    Standalone process entry point.
    static void
    start(int port)
    Starts an embedded test server on the given port without registering a JVM shutdown hook.
    static org.eclipse.jetty.server.Server
    Starts an embedded test server using the configured port.
    static org.eclipse.jetty.server.Server
    startServer(int port)
    Starts an embedded test server on the given port.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • TestServer

      public TestServer()
  • Method Details

    • main

      public static void main(String[] args)
      Standalone process entry point.

      Do not call this method to embed the test server in another application. Use startServer(int) instead so the caller owns the server lifecycle and shutdown order.

    • start

      public static void start(int port)
      Starts an embedded test server on the given port without registering a JVM shutdown hook.

      Callers that need to stop the embedded server explicitly should use startServer(int).

      Parameters:
      port - the port to bind, or 0 to select a random available port
    • startServer

      public static org.eclipse.jetty.server.Server startServer()
      Starts an embedded test server using the configured port.

      The port is resolved from FLUXZERO_PORT, FLUX_PORT, port, or 8888, in that order. The returned Jetty server is owned by the caller and should be stopped by the caller.

      Returns:
      the started Jetty server
    • startServer

      public static org.eclipse.jetty.server.Server startServer(int port)
      Starts an embedded test server on the given port.

      The returned Jetty server is owned by the caller and should be stopped by the caller. This method does not register a JVM shutdown hook, so it can be used safely in applications that coordinate their own shutdown order.

      Parameters:
      port - the port to bind, or 0 to select a random available port
      Returns:
      the started Jetty server