Class AbstractHttpServerImplementationTestCase

java.lang.Object
net.officefloor.server.http.AbstractHttpServerImplementationTestCase
Direct Known Subclasses:
AbstractServletHttpServerImplementationTest

@ExtendWith(TestSupportExtension.class) public abstract class AbstractHttpServerImplementationTestCase extends Object
Abstract TestCase for testing a HttpServerImplementation.
Author:
Daniel Sagenschneider
  • Field Details

  • Constructor Details

    • AbstractHttpServerImplementationTestCase

      public AbstractHttpServerImplementationTestCase()
  • Method Details

    • getRequestCount

      protected int getRequestCount()

      Obtains the request count.

      Allows changing the number for server implementations that have higher overheads.

      Returns:
      Request count.
    • newHttpHeader

      protected static HttpHeader newHttpHeader(String name, String value)
      Creates a new HttpHeader.
      Parameters:
      name - HttpHeader name.
      value - HttpHeader value.
      Returns:
      New HttpHeader.
    • getHttpServerImplementationClass

      protected abstract Class<? extends HttpServerImplementation> getHttpServerImplementationClass()
      Obtains the expected HttpServerImplementation Class being tested.
      Returns:
      Expected HttpServerImplementation Class.
    • startRawHttpServer

      protected abstract AutoCloseable startRawHttpServer(HttpServerLocation serverLocation) throws Exception

      Starts a raw implementation of the underlying HTTP server. This allows performance comparisons of adding in OfficeFloor servicing overheads.

      The raw implementation is to return "hello world" in UTF-8 encoding for the response entity.

      Parameters:
      serverLocation - HttpServerLocation.
      Returns:
      AutoCloseable To stop the server.
      Throws:
      Exception - If fails to start the raw HTTP server.
    • getServerResponseHeaderValues

      protected abstract HttpHeader[] getServerResponseHeaderValues()
      Obtains the server response HttpHeader instances in the order they are sent from the server.
      Returns:
      Server response HttpHeader instances in the order they are sent from the server.
    • getServerNameSuffix

      protected abstract String getServerNameSuffix()
      Obtains the Server HttpHeaderValue suffix.
      Returns:
      Server HttpHeaderValue suffix. May be null if no suffix.
    • setUp

      @BeforeEach public void setUp(org.junit.jupiter.api.TestInfo testInfo) throws Exception
      Sets up the test.
      Parameters:
      testInfo - TestInfo.
      Throws:
      Exception - On test failure.
    • tearDown

      @AfterEach public void tearDown() throws Exception
      Tears down the test.
      Throws:
      Exception - On test failure.
    • startHttpServer

      protected void startHttpServer(Class<?> sectionServicer) throws Exception
      Starts the HttpServer.
      Parameters:
      sectionServicer - Class of the ClassSectionSource to service the HttpRequest.
      Throws:
      Exception - If fails to start the HttpServer.
    • startHttpServer

      protected void startHttpServer(Class<?> sectionServicer, String qualifier, OfficeFloorExtensionService extension) throws Exception
      Starts the HttpServer.
      Parameters:
      sectionServicer - Class of the ClassSectionSource to service the HttpRequest.
      qualifier - Qualifier for the ExternalServiceInput. May be null.
      extension - Additional OfficeFloorExtensionService. May be null.
      Throws:
      Exception - If fails to start the HttpServer.
    • startHttpServer

      protected AutoCloseable startHttpServer(OfficeFloorExtensionService officeFloorExtension, OfficeExtensionService officeExtension) throws Exception
      Starts the HttpServer.
      Parameters:
      officeFloorExtension - OfficeFloorExtensionService to configure the OfficeFloor.
      officeExtension - OfficeExtensionService to configure the OfficeFloor.
      Returns:
      AutoCloseable to stop the server.
      Throws:
      Exception - If fails to start the HttpServer.
    • async

      @Test public void async() throws Exception
      Ensure able to service asynchronous servicing.
      Throws:
      Exception - If test failure.
    • functionality

      @Test public void functionality() throws Exception
      Ensure able to send all details and receive all details.
      Throws:
      Exception - If test failure.
    • qualified

      @Test public void qualified() throws Exception
      Ensure can qualify the ServerHttpConnection.
      Throws:
      Exception - If test failure.
    • rawSingleRequest

      @Test public void rawSingleRequest() throws Exception
      Ensure can handle raw single HTTP request.
      Throws:
      Exception - If test failure.
    • singleRequest

      @Test public void singleRequest() throws Exception
      Ensure can send a single HTTP request.
      Throws:
      Exception - If test failure.
    • singleSecureRequest

      @Test public void singleSecureRequest() throws Exception
      Ensure can send a single HTTPS request.
      Throws:
      Exception - If test failure.
    • singleBufferRequest

      @Test public void singleBufferRequest() throws Exception
      Ensure can send a single HTTP ByteBuffer response.
      Throws:
      Exception - If test failure.
    • singleSecureBufferRequest

      @Test public void singleSecureBufferRequest() throws Exception
      Ensure can send a single HTTPS ByteBuffer response.
      Throws:
      Exception - If test failure.
    • singleFileRequest

      @Test public void singleFileRequest() throws Exception
      Ensure can send a single HTTP StreamBuffer.FileBuffer response.
      Throws:
      Exception - If test failure.
    • singleSecureFileRequest

      @Test public void singleSecureFileRequest() throws Exception
      Ensure can send a single HTTPS StreamBuffer.FileBuffer response.
      Throws:
      Exception - If test failure.
    • serverDateHeaders

      @Test public void serverDateHeaders() throws Exception
      Ensure send Server and Date HttpHeader values.
      Throws:
      Exception - If test failure.
    • getServerName

      protected String getServerName()
      Obtains the server name.
      Returns:
      Server name.
    • singleCloseFileRequest

      @Test public void singleCloseFileRequest() throws Exception
      Ensure closes the FileChannel on write.
      Throws:
      Exception - If test failure.
    • singleSecureCloseFileRequest

      @Test public void singleSecureCloseFileRequest() throws Exception
      Ensure closes the FileChannel on write.
      Throws:
      Exception - If test failure.
    • multipleIndividualRequests

      public void multipleIndividualRequests() throws Exception
      Ensure can send multiple HTTP requests.
      Throws:
      Exception - If test failure.
    • multipleIndividualSecureRequests

      public void multipleIndividualSecureRequests() throws Exception
      Ensure can send multiple HTTPS requests.
      Throws:
      Exception - If test failure.
    • notDecodeRequestUrl

      @Test public void notDecodeRequestUrl() throws Exception
      Ensure does not decode characters (allows for routing to work correctly and not find query string / fragment incorrectly).
      Throws:
      Exception - If test failure.
    • singleThreadedHandlerRequest

      @Test public void singleThreadedHandlerRequest() throws Exception
      Throws:
      Exception - If test failure.
    • secureSingleThreadedHandlerRequest

      @Test public void secureSingleThreadedHandlerRequest() throws Exception
      Ensure can handle request with AbstractHttpServerImplementationTestCase.ThreadedServicer for a secure connection.
      Throws:
      Exception - If test failure.
    • socket

      @Test public void socket() throws Exception
      Ensure raw request.
      Throws:
      Exception - If test failure.
    • secureSocket

      @Test public void secureSocket() throws Exception
      Ensure raw secure request.
      Throws:
      Exception - If test failure.
    • handleError

      @Test public void handleError() throws Exception
      Ensure can handle Escalation.
      Throws:
      Exception - If test failure.
    • teamPressureOverload

      @Test public void teamPressureOverload() throws Exception
      Ensure can handle pressure overloading the server.
      Throws:
      Exception - If test failure.
    • cancelConnection

      @Test public void cancelConnection() throws Exception
      Ensure ProcessState instances for connection are cancelled on loss of connection.
      Throws:
      Exception - If test failure.
    • secureCancelConnection

      @Test public void secureCancelConnection() throws Exception
      Ensure ProcessState instances for connection are cancelled on loss of secure connection.
      Throws:
      Exception - If test failure.
    • isHandleCancel

      protected boolean isHandleCancel()
      Indicates if handle cancel.
      Returns:
      true if handle cancel.
    • rawPipelineVerify

      @Test public void rawPipelineVerify() throws Exception
      Verify pipeline HTTP requests.
      Throws:
      Exception - If test failure.
    • bytesPipelineVerify

      @Test public void bytesPipelineVerify() throws Exception
      Verify pipeline HTTP requests.
      Throws:
      Exception - If test failure.
    • bufferPipelineVerify

      @Test public void bufferPipelineVerify() throws Exception
      Verify pipeline HTTP requests.
      Throws:
      Exception - If test failure.
    • filePipelineVerify

      @Test public void filePipelineVerify() throws Exception
      Verify pipeline HTTP requests.
      Throws:
      Exception - If test failure.
    • doPipelineVerifyTest

      public void doPipelineVerifyTest(Class<?> servicerClass) throws Exception
      Undertakes verifying the pipeline tests.
      Parameters:
      servicerClass - Servicer Class.
      Throws:
      Exception - If fails test.
    • rawPipelining

      public void rawPipelining() throws Exception
      Ensure can pipeline HTTP requests.
      Throws:
      Exception - If test failure.
    • bytesPipelining

      public void bytesPipelining() throws Exception
      Ensure can pipeline HTTP requests.
      Throws:
      Exception - If test failure.
    • bufferPipelining

      public void bufferPipelining() throws Exception
      Ensure can pipeline HTTP requests.
      Throws:
      Exception - If test failure.
    • filePipelining

      public void filePipelining() throws Exception
      Ensure can pipeline HTTP requests.
      Throws:
      Exception - If test failure.
    • rawThreadedHandler

      public void rawThreadedHandler() throws Exception
      Ensure can handle HTTP requests with threaded handler.
      Throws:
      Exception - If test failure.
    • bytesThreadedHandler

      public void bytesThreadedHandler() throws Exception
      Ensure can handle HTTP requests with threaded handler.
      Throws:
      Exception - If test failure.
    • bufferThreadedHandler

      public void bufferThreadedHandler() throws Exception
      Ensure can handle HTTP requests with threaded handler.
      Throws:
      Exception - If test failure.
    • fileThreadedHandler

      public void fileThreadedHandler() throws Exception
      Ensure can handle HTTP requests with threaded handler.
      Throws:
      Exception - If test failure.
    • rawHeavyLoad

      public void rawHeavyLoad() throws Exception
      Ensure can service multiple requests pipelined.
      Throws:
      Exception - If test failure.
    • bytesHeavyLoad

      public void bytesHeavyLoad() throws Exception
      Ensure can service multiple requests pipelined.
      Throws:
      Exception - If test failure.
    • bufferHeavyLoad

      public void bufferHeavyLoad() throws Exception
      Ensure can service multiple requests pipelined.
      Throws:
      Exception - If test failure.
    • fileHeavyLoad

      public void fileHeavyLoad() throws Exception
      Ensure can service multiple requests pipelined.
      Throws:
      Exception - If test failure.
    • rawOverLoad

      public void rawOverLoad() throws Exception
      Ensure can service over requests pipelined.
      Throws:
      Exception - If test failure.
    • bytesOverLoad

      public void bytesOverLoad() throws Exception
      Ensure can service overload requests pipelined.
      Throws:
      Exception - If test failure.
    • bufferOverLoad

      public void bufferOverLoad() throws Exception
      Ensure can service overload requests pipelined.
      Throws:
      Exception - If test failure.
    • fileOverLoad

      public void fileOverLoad() throws Exception
      Ensure can service overload requests pipelined.
      Throws:
      Exception - If test failure.
    • doMultiClientLoadTest

      public void doMultiClientLoadTest(Class<?> servicerClass, int clientCount, int requestCount, String resultName) throws Exception
      Undertakes the multi-client pipelining test.
      Parameters:
      servicerClass - Servicer Class.
      clientCount - Number of simultaneous clients.
      requestCount - Number of requests per client.
      resultName - Name of result for comparison.
      Throws:
      Exception - If test failure.