Class AbstractHttpServerImplementationTest<M>

  • Type Parameters:
    M - Type of momento from raw HTTP server.
    All Implemented Interfaces:
    junit.framework.Test

    public abstract class AbstractHttpServerImplementationTest<M>
    extends OfficeFrameTestCase
    Abstract TestCase for testing a HttpServerImplementation.
    Author:
    Daniel Sagenschneider
    • Constructor Detail

      • AbstractHttpServerImplementationTest

        public AbstractHttpServerImplementationTest()
    • Method Detail

      • getRequestCount

        protected int getRequestCount()

        Obtains the request count.

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

        Returns:
        Request count.
      • startRawHttpServer

        protected abstract M startRawHttpServer​(HttpServerLocation serverLocation)
                                         throws java.lang.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:
        Momento to provide to stopping the server.
        Throws:
        java.lang.Exception - If fails to start the raw HTTP server.
      • stopRawHttpServer

        protected abstract void stopRawHttpServer​(M momento)
                                           throws java.lang.Exception
        Stops the raw implementation.
        Parameters:
        momento - Momento provided from starting the raw HTTP server.
        Throws:
        java.lang.Exception - If fails to stop 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 java.lang.String getServerNameSuffix()
        Obtains the Server HttpHeaderValue suffix.
        Returns:
        Server HttpHeaderValue suffix. May be null if no suffix.
      • setUp

        protected void setUp()
                      throws java.lang.Exception
        Overrides:
        setUp in class junit.framework.TestCase
        Throws:
        java.lang.Exception
      • tearDown

        protected void tearDown()
                         throws java.lang.Exception
        Overrides:
        tearDown in class junit.framework.TestCase
        Throws:
        java.lang.Exception
      • startHttpServer

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

        public void testFunctionality()
                               throws java.lang.Exception
        Ensure able to send all details and receive all details.
        Throws:
        java.lang.Exception - If test failure.
      • testRawSingleRequest

        public void testRawSingleRequest()
                                  throws java.lang.Exception
        Ensure can handle raw single HTTP request.
        Throws:
        java.lang.Exception - If test failure.
      • testSingleRequest

        public void testSingleRequest()
                               throws java.lang.Exception
        Ensure can send a single HTTP request.
        Throws:
        java.lang.Exception - If test failure.
      • testSingleSecureRequest

        public void testSingleSecureRequest()
                                     throws java.lang.Exception
        Ensure can send a single HTTPS request.
        Throws:
        java.lang.Exception - If test failure.
      • testSingleBufferRequest

        public void testSingleBufferRequest()
                                     throws java.lang.Exception
        Ensure can send a single HTTP ByteBuffer response.
        Throws:
        java.lang.Exception - If test failure.
      • testSingleSecureBufferRequest

        public void testSingleSecureBufferRequest()
                                           throws java.lang.Exception
        Ensure can send a single HTTPS ByteBuffer response.
        Throws:
        java.lang.Exception - If test failure.
      • testSingleFileRequest

        public void testSingleFileRequest()
                                   throws java.lang.Exception
        Ensure can send a single HTTP StreamBuffer.FileBuffer response.
        Throws:
        java.lang.Exception - If test failure.
      • testSingleSecureFileRequest

        public void testSingleSecureFileRequest()
                                         throws java.lang.Exception
        Ensure can send a single HTTPS StreamBuffer.FileBuffer response.
        Throws:
        java.lang.Exception - If test failure.
      • testServerDateHeaders

        public void testServerDateHeaders()
                                   throws java.lang.Exception
        Ensure send Server and Date HttpHeader values.
        Throws:
        java.lang.Exception - If test failure.
      • getServerName

        protected java.lang.String getServerName()
        Obtains the server name.
        Returns:
        Server name.
      • testSingleCloseFileRequest

        public void testSingleCloseFileRequest()
                                        throws java.lang.Exception
        Ensure closes the FileChannel on write.
        Throws:
        java.lang.Exception - If test failure.
      • testSingleSecureCloseFileRequest

        public void testSingleSecureCloseFileRequest()
                                              throws java.lang.Exception
        Ensure closes the FileChannel on write.
        Throws:
        java.lang.Exception - If test failure.
      • testMultipleIndividualRequests

        public void testMultipleIndividualRequests()
                                            throws java.lang.Exception
        Ensure can send multiple HTTP requests.
        Throws:
        java.lang.Exception - If test failure.
      • testMultipleIndividualSecureRequests

        public void testMultipleIndividualSecureRequests()
                                                  throws java.lang.Exception
        Ensure can send multiple HTTPS requests.
        Throws:
        java.lang.Exception - If test failure.
      • testNotDecodeRequestUrl

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

        public void testSecureSingleThreadedHandlerRequest()
                                                    throws java.lang.Exception
        Ensure can handle request with AbstractHttpServerImplementationTest.ThreadedServicer for a secure connection.
        Throws:
        java.lang.Exception - If test failure.
      • testSocket

        public void testSocket()
                        throws java.lang.Exception
        Ensure raw request.
        Throws:
        java.lang.Exception - If test failure.
      • testSecureSocket

        public void testSecureSocket()
                              throws java.lang.Exception
        Ensure raw secure request.
        Throws:
        java.lang.Exception - If test failure.
      • testHandleError

        public void testHandleError()
                             throws java.lang.Exception
        Ensure can handle Escalation.
        Throws:
        java.lang.Exception - If test failure.
      • testTeamPressureOverload

        public void testTeamPressureOverload()
                                      throws java.lang.Exception
        Ensure can handle pressure overloading the server.
        Throws:
        java.lang.Exception - If test failure.
      • testCancelConnection

        public void testCancelConnection()
                                  throws java.lang.Exception
        Ensure ProcessState instances for connection are cancelled on loss of connection.
        Throws:
        java.lang.Exception - If test failure.
      • testSecureCancelConnection

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

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

        public void testRawPipelineVerify()
                                   throws java.lang.Exception
        Verify pipeline HTTP requests.
        Throws:
        java.lang.Exception - If test failure.
      • testBytesPipelineVerify

        public void testBytesPipelineVerify()
                                     throws java.lang.Exception
        Verify pipeline HTTP requests.
        Throws:
        java.lang.Exception - If test failure.
      • testBufferPipelineVerify

        public void testBufferPipelineVerify()
                                      throws java.lang.Exception
        Verify pipeline HTTP requests.
        Throws:
        java.lang.Exception - If test failure.
      • testFilePipelineVerify

        public void testFilePipelineVerify()
                                    throws java.lang.Exception
        Verify pipeline HTTP requests.
        Throws:
        java.lang.Exception - If test failure.
      • doPipelineVerifyTest

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

        public void testRawPipelining()
                               throws java.lang.Exception
        Ensure can pipeline HTTP requests.
        Throws:
        java.lang.Exception - If test failure.
      • testBytesPipelining

        public void testBytesPipelining()
                                 throws java.lang.Exception
        Ensure can pipeline HTTP requests.
        Throws:
        java.lang.Exception - If test failure.
      • testBufferPipelining

        public void testBufferPipelining()
                                  throws java.lang.Exception
        Ensure can pipeline HTTP requests.
        Throws:
        java.lang.Exception - If test failure.
      • testFilePipelining

        public void testFilePipelining()
                                throws java.lang.Exception
        Ensure can pipeline HTTP requests.
        Throws:
        java.lang.Exception - If test failure.
      • testRawThreadedHandler

        public void testRawThreadedHandler()
                                    throws java.lang.Exception
        Ensure can handle HTTP requests with threaded handler.
        Throws:
        java.lang.Exception - If test failure.
      • testBytesThreadedHandler

        public void testBytesThreadedHandler()
                                      throws java.lang.Exception
        Ensure can handle HTTP requests with threaded handler.
        Throws:
        java.lang.Exception - If test failure.
      • testBufferThreadedHandler

        public void testBufferThreadedHandler()
                                       throws java.lang.Exception
        Ensure can handle HTTP requests with threaded handler.
        Throws:
        java.lang.Exception - If test failure.
      • testFileThreadedHandler

        public void testFileThreadedHandler()
                                     throws java.lang.Exception
        Ensure can handle HTTP requests with threaded handler.
        Throws:
        java.lang.Exception - If test failure.
      • testRawHeavyLoad

        public void testRawHeavyLoad()
                              throws java.lang.Exception
        Ensure can service multiple requests pipelined.
        Throws:
        java.lang.Exception - If test failure.
      • testBytesHeavyLoad

        public void testBytesHeavyLoad()
                                throws java.lang.Exception
        Ensure can service multiple requests pipelined.
        Throws:
        java.lang.Exception - If test failure.
      • testBufferHeavyLoad

        public void testBufferHeavyLoad()
                                 throws java.lang.Exception
        Ensure can service multiple requests pipelined.
        Throws:
        java.lang.Exception - If test failure.
      • testFileHeavyLoad

        public void testFileHeavyLoad()
                               throws java.lang.Exception
        Ensure can service multiple requests pipelined.
        Throws:
        java.lang.Exception - If test failure.
      • testRawOverLoad

        public void testRawOverLoad()
                             throws java.lang.Exception
        Ensure can service over requests pipelined.
        Throws:
        java.lang.Exception - If test failure.
      • testBytesOverLoad

        public void testBytesOverLoad()
                               throws java.lang.Exception
        Ensure can service overload requests pipelined.
        Throws:
        java.lang.Exception - If test failure.
      • testBufferOverLoad

        public void testBufferOverLoad()
                                throws java.lang.Exception
        Ensure can service overload requests pipelined.
        Throws:
        java.lang.Exception - If test failure.
      • testFileOverLoad

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

        public void doMultiClientLoadTest​(java.lang.Class<?> servicerClass,
                                          int clientCount,
                                          int requestCount,
                                          java.lang.String resultName)
                                   throws java.lang.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:
        java.lang.Exception - If test failure.