Class BaseJettyServerExtension<T extends BaseJettyServerExtension<?>>

java.lang.Object
ca.uhn.fhir.test.utilities.server.BaseJettyServerExtension<T>
All Implemented Interfaces:
org.junit.jupiter.api.extension.AfterAllCallback, org.junit.jupiter.api.extension.AfterEachCallback, org.junit.jupiter.api.extension.BeforeEachCallback, org.junit.jupiter.api.extension.Extension
Direct Known Subclasses:
HttpServletExtension, RestfulServerExtension

public abstract class BaseJettyServerExtension<T extends BaseJettyServerExtension<?>> extends Object implements org.junit.jupiter.api.extension.BeforeEachCallback, org.junit.jupiter.api.extension.AfterEachCallback, org.junit.jupiter.api.extension.AfterAllCallback
  • Constructor Details

  • Method Details

    • withIdleTimeout

      public T withIdleTimeout(long theIdleTimeoutMillis)
      Sets the Jetty server "idle timeout" in millis. This is the amount of time that the HTTP processor will allow a request to take before it hangs up on the client. This means the amount of time receiving the request over the network or streaming the response, not the amount of time spent actually processing the request (ie this is a network timeout, not a CPU timeout). Default is 30000.
    • withContextPath

      public T withContextPath(String theContextPath)
    • getConnectionsOpenedCount

      Returns the total number of connections that this server has received. This is not the current number of open connections, it's the number of new connections that have been opened at any point.
    • resetConnectionsOpenedCount

    • getHttpClient

      public org.apache.http.impl.client.CloseableHttpClient getHttpClient()
    • getRequestContentTypes

    • getRequestHeaders

    • stopServer

      @PreDestroy public void stopServer() throws Exception
      Throws:
      Exception
    • startServer

      protected void startServer() throws Exception
      Throws:
      Exception
    • getPort

      public int getPort()
    • provideServlet

      protected abstract javax.servlet.http.HttpServlet provideServlet()
    • getWebsocketContextPath

    • withServletPath

      public T withServletPath(String theServletPath)
      Should be in the format /the/path/*
    • withPort

      public T withPort(int thePort)
    • keepAliveBetweenTests

    • isRunning

      protected boolean isRunning()
    • getBaseUrl

      public String getBaseUrl()
      Returns the server base URL with no trailing slash
    • beforeEach

      public void beforeEach(org.junit.jupiter.api.extension.ExtensionContext context) throws Exception
      Specified by:
      beforeEach in interface org.junit.jupiter.api.extension.BeforeEachCallback
      Throws:
      Exception
    • afterEach

      public void afterEach(org.junit.jupiter.api.extension.ExtensionContext context) throws Exception
      Specified by:
      afterEach in interface org.junit.jupiter.api.extension.AfterEachCallback
      Throws:
      Exception
    • afterAll

      public void afterAll(org.junit.jupiter.api.extension.ExtensionContext context) throws Exception
      Specified by:
      afterAll in interface org.junit.jupiter.api.extension.AfterAllCallback
      Throws:
      Exception
    • withSpringWebsocketSupport

      public T withSpringWebsocketSupport(String theContextPath, Class<? extends org.springframework.web.socket.config.annotation.WebSocketConfigurer> theContextConfigClass)
      To use this method, you need to add the following to your test class: @TestExecutionListeners(value = SpringContextGrabbingTestExecutionListener.class, mergeMode = TestExecutionListeners.MergeMode.MERGE_WITH_DEFAULTS)