Class EphemeralJettyServerConfig

java.lang.Object
org.apache.juneau.microservice.test.EphemeralJettyServerConfig

A @Configuration that supplies a Jetty Server bound to an OS-assigned ephemeral port (port 0) for use by @MicroserviceTest-driven integration tests.

The server has a single ServerConnector on port 0 and a single root ServletContextHandler at context path "/". JettyServerComponent discovers the handler via the "ServletContextHandler" server attribute (the same convention used by jetty.xml).

The extension installs this @Configuration automatically after the user-supplied configurations, so a user-supplied @Bean Server (if any) still wins (the bean store returns the first registered match). Tests supply their @Bean Servlet definitions, which JettyServerComponent auto-mounts at the resource's @Rest(path=...).

Since:
10.0.0
  • Constructor Details

  • Method Details

    • jettyServer

      public org.eclipse.jetty.server.Server jettyServer()
      Provides the bean-supplied Jetty Server that JettyServerComponent consumes during onStart().
      Returns:
      A configured Server bound to port 0 (OS-assigned ephemeral port).
    • jettySettings

      Disables the 30s graceful-shutdown drain wait for integration tests.

      JettyServerComponent applies a 30s stopTimeout default to support zero-downtime k8s rollouts. In ephemeral test servers there are no load balancers or in-flight production traffic, so the drain wait only adds ~1s per test class to the suite runtime. Setting it to zero restores fast shutdown.

      Returns:
      JettySettings with stopTimeout set to zero.